[ 
https://jira.codehaus.org/browse/MFINDBUGS-146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gan Yang updated MFINDBUGS-146:
-------------------------------

    Comment: was deleted

(was: it seems findbugs-maven-plugin-2.4.0 doesn't support  
<includeFilterFile>http://svn.xxx.dev/repos/quality-profile/findbugs.xml</includeFilterFile>
 as a "http url"
like maven-checkstyle-plugin and maven-pmd-plugin do.

it couldnt be better to have findbugs-maven-plugin support it this way.)
    
> Report cannot correctly handle external FindBugs ruleset as exported by Sonar 
> QA Dashboard
> ------------------------------------------------------------------------------------------
>
>                 Key: MFINDBUGS-146
>                 URL: https://jira.codehaus.org/browse/MFINDBUGS-146
>             Project: Maven 2.x FindBugs Plugin
>          Issue Type: Bug
>    Affects Versions: 2.3.2
>         Environment: OS: Microsoft Windows 7 Professional x86 64-bit NL
> Java: JDK 1.6.0_22 64-bit
> Maven: 3.0.3
> Maven cmd: clean deploy site:site site:deploy 
>            Reporter: Tjerk Stroband
>            Assignee: Garvin LeClaire
>             Fix For: 2.4.0
>
>
> Sonar (http://www.sonarsource.org/) offers a way to centrally manage the 
> FindBugs ruleset configuration and publish the specified configuration on a 
> URL.
> The url takes the following form:
> http://nemo.sonarsource.org/profiles/export?format=findbugs&language=java&name=Nemo%2520rules%2520with%2520findbugs
> Plugin config:
> {code:xml}
> <plugin>
>    <groupId>org.codehaus.mojo</groupId>
>    <artifactId>findbugs-maven-plugin</artifactId>
>    <!-- version>2.3.2</version -->
>    <configuration>
>       <effort>Max</effort>
>       <threshold>Low</threshold>
>       
> <includeFilterFile>http://nemo.sonarsource.org/profiles/export?format=findbugs&amp;language=java&amp;name=Nemo%2520rules%2520with%2520findbugs</includeFilterFile>
>    </configuration>
> </plugin>
> {code}
> When generating a FindBugs report (as part of site:site) the plugin fails (on 
> specified environment) with the following error:
> {noformat}
> [INFO] Generating "FindBugs Report" report    --- findbugs-maven-plugin:2.3.2
> ...<snip>...
> [DEBUG]   Adding Include Filter Files 
> [DEBUG] resource is 
> http://nemo.sonarsource.org/profiles/export?format=findbugs&language=java&name=Nemo%2520rules%2520with%2520findbugs
> [DEBUG] location is http://nemo.sonarsource.org/profiles
> [DEBUG] artifact is 
> export?format=findbugs&language=java&name=Nemo%2520rules%2520with%2520findbugs
> [DEBUG] URLResourceLoader: Found 
> 'http://nemo.sonarsource.org/profiles/export?format=findbugs&language=java&name=Nemo%2520rules%2520with%2520findbugs'
>  at ''
> [DEBUG] The resource 
> 'http://nemo.sonarsource.org/profiles/export?format=findbugs&language=java&name=Nemo%2520rules%2520with%2520findbugs'
>  found using the 
> org.codehaus.plexus.resource.loader.URLResourceLoader@af094f2.
> ...<snip>...
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO] 
> ------------------------------------------------------------------------
> ...<snip>...
> [ERROR] Cannot create file-based resource. 
> <myproject-root>\target\export?format=findbugs&language=java&name=Nemo%2520rules%2520with%2520findbugs
>  (De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist) -> [Help 
> 1]
> org.codehaus.plexus.resource.loader.FileResourceCreationException: Cannot 
> create file-based resource.
>       at 
> org.codehaus.plexus.resource.DefaultResourceManager.getResourceAsFile(DefaultResourceManager.java:154)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
>       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
>       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756)
>       at 
> org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:738)
>       at 
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:726)
>       at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:170)
>       at 
> org.codehaus.mojo.findbugs.FindBugsMojo.getResourceFile(FindBugsMojo.groovy:1059)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
>       at 
> org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:338)
>       at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:78)
>       at 
> org.codehaus.mojo.findbugs.FindBugsMojo$_executeFindbugs_closure4_closure12.doCall(FindBugsMojo.groovy:825)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
>       at 
> org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:249)
>       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756)
>       at groovy.lang.Closure.call(Closure.java:292)
>       at groovy.lang.Closure.call(Closure.java:305)
>       at 
> org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1068)
>       at 
> org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1045)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:51)
>       at 
> org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:54)
>       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
>       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
>       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756)
>       at 
> org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:738)
>       at 
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:726)
>       at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:170)
>       at 
> org.codehaus.mojo.findbugs.FindBugsMojo$_executeFindbugs_closure4.doCall(FindBugsMojo.groovy:823)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
>       at 
> org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:249)
>       at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:78)
>       at 
> org.codehaus.mojo.findbugs.FindBugsMojo$_executeFindbugs_closure4.doCall(FindBugsMojo.groovy)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
>       at 
> org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:249)
>       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756)
>       at groovy.lang.Closure.call(Closure.java:292)
>       at groovy.lang.Closure.call(Closure.java:287)
>       at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:143)
>       at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:149)
>       at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64)
>       at 
> org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:756)
>       at 
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:730)
>       at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:170)
>       at 
> org.codehaus.mojo.findbugs.FindBugsMojo.executeFindbugs(FindBugsMojo.groovy:760)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
>       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
>       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
>       at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:78)
>       at 
> org.codehaus.mojo.findbugs.FindBugsMojo.executeReport(FindBugsMojo.groovy:562)
>       at 
> org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:190)
>       at 
> org.apache.maven.plugins.site.ReportDocumentRenderer.renderDocument(ReportDocumentRenderer.java:165)
>       at 
> org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderModule(DefaultSiteRenderer.java:330)
>       at 
> org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render(DefaultSiteRenderer.java:134)
>       at 
> org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:159)
>       at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:122)
>       at 
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
>       at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
>       at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>       at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>       at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>       at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
>       at 
> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
>       at 
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
>       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
>       at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
>       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
>       at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
>       at 
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
>       at 
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
>       at 
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
>       at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
> Caused by: java.io.FileNotFoundException: 
> <myproject-root>\target\export?format=findbugs&language=java&name=Nemo%2520rules%2520with%2520findbugs
>  (De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist)
>       at java.io.FileOutputStream.open(Native Method)
>       at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
>       at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
>       at java.io.FileWriter.<init>(FileWriter.java:73)
>       at 
> org.codehaus.plexus.resource.DefaultResourceManager.getResourceAsFile(DefaultResourceManager.java:148)
>       ... 114 more
> {noformat}
> The problem is that the temporary filename constructed from the URL contains 
> illegal characters.
> I tracked it down to the following class/line: 
> {{maven-findbugs-plugin/src/main/groovy/org/codehaus/mojo/findbugs/FindBugsMojo.java
>  line 1040}}.
> The method {{File getResourceFile(String)}} is not accommodating weird 
> characters in the resource name that are not allowed on the filesystem.
> {code:java}
> protected File getResourceFile(String resource) {
>     assert resource
>     String location = null
>     String artifact = resource
>     if ( resource.indexOf('/') != -1 ) {
>       artifact = resource.substring(resource.lastIndexOf('/') + 1)
>     }
>     if ( resource.indexOf('/') != -1 ) {
>       location = resource.substring(0, resource.lastIndexOf('/'))
>     }
>     log.debug("resource is " + resource)
>     log.debug("location is " + location)
>     log.debug("artifact is " + artifact)
>     File resourceFile = resourceManager.getResourceAsFile(resource, artifact)
>     log.debug("location of configFile file is " + resourceFile)
>     return resourceFile
>   }
> {code}
> Adding the following lines right before the {{log.debug}} statements should 
> fix it:
> {code:java}
>     // in the case that the rules are defined externally on a url
>     // we need to replace some special url characters that cannot be
>     // used in filenames on disk or produce ackward filenames.
>     // replace all occurrences of the following characters:  ? : & =
>     location = location.replaceAll("[\\?\\:\\&\\=\\%]", "_");
> {code}
> This issue is similar to a problem i reported on PMD-plugin 
> http://jira.codehaus.org/browse/MPMD-127
> The fix is the same...
> As I'm unfamiliar with the way the unit-test on the project are setup I'm not 
> sure where to include the testcase for this. However, the test would look 
> like the following code fragment:
> {code:java}
>     /**
>      * Verify the correct working of the getResourceFile method
>      * In particular, check the resulting filename does not contain illegal 
> characters
>      *
>      * @throws Exception
>      */
>       public void testGetResourceFileNameCharacters() throws Exception {
>               FindBugsMojo mojo = // get it somewhere;
>               assertEquals(
>                               "getResourceFile is not correctly encoding 
> filename",
>                               
> "export_format_findbugs_language_java_name_some_2520name",
>                               
> mojo.getResourceFile("export?format=findbugs&language=java&name=some%2520name"));
>       }
> {code} 
> As I am not a developer on the project I cannot apply this fix. Is anyone on 
> the development team willing to do this for me?
> If required I can create a patch. I assume on the latest trunk of 
> 2.3.3-SNAPSHOT...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to