SonarQube
  1. SonarQube
  2. SONAR-2477

Allow to use FindBugs filter-files with exclusions

    Details

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

      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");
        }
      
      1. SONAR-2477-example.tar.gz
        0.7 kB
        OLD - Evgeny Mandrikov

        Activity

        Michael Crawford created issue -
        Freddy Mallet made changes -
        Field Original Value New Value
        Fix Version/s 2.10 [ 17370 ]
        Freddy Mallet made changes -
        Assignee Evgeny Mandrikov [ godin ]
        OLD - Evgeny Mandrikov made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        OLD - 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)
        OLD - 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
        OLD - Evgeny Mandrikov made changes -
        Summary Allow to use Findbugs filter-files with exclusions Allow to use FindBugs filter-files with exclusions
        OLD - Evgeny Mandrikov made changes -
        Original Estimate 0 minutes [ 0 ]
        Remaining Estimate 0 minutes [ 0 ]
        Assignee Evgeny Mandrikov [ godin ] Freddy Mallet [ freddy.mallet ]
        OLD - 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 ]
        OLD - Evgeny Mandrikov made changes -
        Status Reopened [ 4 ] In Progress [ 3 ]
        OLD - Evgeny Mandrikov made changes -
        Attachment SONAR-2477-example.tar.gz [ 56154 ]
        OLD - Evgeny Mandrikov made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Assignee Evgeny Mandrikov [ godin ] Freddy Mallet [ freddy.mallet ]
        Freddy Mallet made changes -
        Assignee Freddy Mallet [ freddy.mallet ] Evgeny Mandrikov [ godin ]
        Simon Brandhof made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        OLD - Fabrice Bellingard made changes -
        Component/s Findbugs [ 13738 ]
        Henri Gomez made changes -
        Project Import Wed May 27 13:41:49 CEST 2015 [ 1432726909095 ]
        Henri Gomez made changes -
        Project Import Thu May 28 19:38:02 UTC 2015 [ 1432841882590 ]
        Freddy Mallet made changes -
        Workflow jira [ 31454 ] Default SonarSource Workflow [ 56559 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: