Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
JENKINS-20147: Add include and exclude files patterns
Browse files Browse the repository at this point in the history
Add include patterns option to include files in the report based on
their absolute paths.
Add exclude patterns option to exclude files from the report based on
their absolute paths.

Issue: JENKINS-20147
Change-Id: I2220dc9b613bd95d4fbd1b0bd102f578c359e862
  • Loading branch information
meg authored and Geraldo Mecja committed Nov 11, 2013
1 parent 562d2ce commit dc16e50
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 34 deletions.
Expand Up @@ -58,6 +58,7 @@ public class FindBugsParser implements AnnotationParser {
private static final String DOT = ".";
private static final String SLASH = "/";
private static final String CLOUD_DETAILS_URL_PROPERTY = "detailsUrl";
private static final String EMPTY_STRING = "";

private static final int DAY_IN_MSEC = 1000 * 60 * 60 * 24;
private static final int HIGH_PRIORITY_LOWEST_RANK = 4;
Expand All @@ -83,7 +84,7 @@ public class FindBugsParser implements AnnotationParser {
* determines whether to use the rank when evaluation the priority
*/
public FindBugsParser(final boolean isRankActivated) {
this(isRankActivated, null, null);
this(isRankActivated, EMPTY_STRING, EMPTY_STRING);
}

/**
Expand Down Expand Up @@ -312,18 +313,18 @@ private Collection<FileAnnotation> parse(final InputStream file, final Collectio

}

return applyExcludeFilter(annotations);
return applyFilters(annotations);
}


/**
* Applies the exclude filter to the found annotations.
* Applies the exclude and include filters to the found annotations.
*
* @param allAnnotations
* all annotations
* @return the filtered annotations if there is a filter defined
*/
private List<FileAnnotation> applyExcludeFilter(final List<FileAnnotation> allAnnotations) {
private List<FileAnnotation> applyFilters(final List<FileAnnotation> allAnnotations) {
List<FileAnnotation> includedAnnotations;
if (includePatterns.isEmpty()) {
includedAnnotations = allAnnotations;
Expand Down
16 changes: 16 additions & 0 deletions plugin/src/main/resources/findbugs/filter.jelly
@@ -0,0 +1,16 @@
<!--
Section header
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">

<f:entry title="${%Bugs to include}" field="includePattern" description="${%description.includePattern}">
<f:textbox />
</f:entry>
<f:entry title="${%Bugs to ignore}" field="excludePattern" description="${%description.excludePattern}">
<f:textbox />
</f:entry>

</j:jelly>
7 changes: 7 additions & 0 deletions plugin/src/main/resources/findbugs/filter.properties
@@ -0,0 +1,7 @@
description.includePattern=Comma separated list of \
<a href="http://download.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html">regular expressions</a> \
that specifies the files to include in the report (based on their absolute filename). \
If this field is empty then all files are included.
description.excludePattern=Comma separated list of \
<a href="http://download.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html">regular expressions</a> \
that specifies the files to exclude from the report (based on their absolute filename).
Expand Up @@ -7,13 +7,7 @@
</f:entry>
<fb:rank />
<f:advanced>
<f:entry title="${%Bugs to include}" field="includePattern" description="${%description.includePattern}">
<f:textbox />
</f:entry>
<f:entry title="${%Bugs to ignore}" field="excludePattern" description="${%description.excludePattern}">
<f:textbox />
</f:entry>

<fb:filter/>
<u:advanced id="findbugs" />
</f:advanced>
</j:jelly>
Expand Up @@ -5,10 +5,3 @@ description.pattern=<a href="{0}">Fileset 'includes'</a> \
If no value is set, then the default '**/findbugsXml.xml' or '**/findbugs.xml' \
are used for maven or ant builds, respectively. Be sure not to include any \
non-report files into this pattern.
description.includePattern=Comma separated list of \
<a href="http://download.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html">regular expressions</a> \
that specifies the files to include in the report (based on their absolute filename). \
If this field is empty then all files are included.
description.excludePattern=Comma separated list of \
<a href="http://download.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html">regular expressions</a> \
that specifies the files to exclude from the report (based on their absolute filename).
@@ -1,19 +1,9 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:u="/util" xmlns:fb="/findbugs">
<f:entry title="${%FindBugs results}" field="pattern"
description="${%description.pattern('http://ant.apache.org/manual/Types/fileset.html')}">
<f:textbox />
</f:entry>
<fb:rank />
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:u="/util" xmlns:fb="/findbugs">
<fb:rank/>
<f:advanced>
<f:entry title="${%Bugs to include}" field="includePattern" description="${%description.includePattern}">
<f:textbox />
</f:entry>
<f:entry title="${%Bugs to ignore}" field="excludePattern" description="${%description.excludePattern}">
<f:textbox />
</f:entry>

<u:advanced id="findbugs" />
<fb:filter/>
<u:advancedMaven id="findbugs"/>
</f:advanced>
</j:jelly>
</j:jelly>

0 comments on commit dc16e50

Please sign in to comment.