SonarQube
  1. SonarQube
  2. SONAR-2477

Allow to use FindBugs filter-files with exclusions

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.8
    • Fix Version/s: 2.10
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      It is not possible to utilise a Findbugs excludes filter file when performing analysis of projects. This functionality would have existed in previous versions of Sonar, but was removed as you discussed here - http://old.nabble.com/Sonar-2.5-is-not-honoring-FindBugs-exclussions-filter-defined-in-pom.xml-td30947735.html

      Would it be possible to alter the current Findbugs plugin (specifically the FindbugsConfiguration.saveExcludeConfigXml() method) to allow the user to specify an excludes file in the configuration to offer a degree of backwards compatibility?

      An example (but untested) fix follows:

        public File saveExcludeConfigXml() throws IOException {
      	  
      	// Example fix follows:
      	try {
      		String excludesFileLocation = project.getConfiguration().getString("sonar.findbugs.includesFilter");
      		if (excludesFileLocation != null && !excludesFileLocation.isEmpty()) {
      			File filter = new File(excludesFileLocation);
      			if (filter.exists()) {
      				return filter;
      			}
      		}
      	} catch (NoSuchElementException e) {
      		// log the exception here and proceed as before...
      	}
      	// End of example fix.
      	  
          FindBugsFilter findBugsFilter = new FindBugsFilter();
          if (project.getExclusionPatterns() != null) {
            for (String exclusion : project.getExclusionPatterns()) {
              ClassFilter classFilter = new ClassFilter(FindbugsAntConverter.antToJavaRegexpConvertor(exclusion));
              findBugsFilter.addMatch(new Match(classFilter));
            }
          }
          return project.getFileSystem().writeToWorkingDirectory(findBugsFilter.toXml(), "findbugs-exclude.xml");
        }
      

        Activity

        Freddy Mallet made changes -
        Field Original Value New Value
        Fix Version/s 2.10 [ 17370 ]
        Freddy Mallet made changes -
        Assignee Evgeny Mandrikov [ godin ]
        Evgeny Mandrikov made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Evgeny Mandrikov made changes -
        Summary It is not possible to use Findbugs exclusion filter files (regression) It is not possible to use Findbugs filter-files with exclusions (regression)
        Evgeny Mandrikov made changes -
        Summary It is not possible to use Findbugs filter-files with exclusions (regression) Allow to use Findbugs filter-files with exclusions
        Evgeny Mandrikov made changes -
        Summary Allow to use Findbugs filter-files with exclusions Allow to use FindBugs filter-files with exclusions
        Evgeny Mandrikov made changes -
        Original Estimate 0 minutes [ 0 ]
        Remaining Estimate 0 minutes [ 0 ]
        Assignee Evgeny Mandrikov [ godin ] Freddy Mallet [ freddy.mallet ]
        Evgeny Mandrikov made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Freddy Mallet made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Assignee Freddy Mallet [ freddy.mallet ] Evgeny Mandrikov [ godin ]
        Evgeny Mandrikov made changes -
        Status Reopened [ 4 ] In Progress [ 3 ]
        Evgeny Mandrikov made changes -
        Attachment SONAR-2477-example.tar.gz [ 56154 ]
        Evgeny Mandrikov made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Assignee Evgeny Mandrikov [ godin ] Freddy Mallet [ freddy.mallet ]
        Resolution Fixed [ 1 ]
        Freddy Mallet made changes -
        Assignee Freddy Mallet [ freddy.mallet ] Evgeny Mandrikov [ godin ]
        Simon Brandhof made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Fabrice Bellingard made changes -
        Component/s Findbugs [ 13738 ]

          People

          • Assignee:
            Evgeny Mandrikov
            Reporter:
            Michael Crawford
          • Votes:
            9 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: