Skip to content

Commit

Permalink
Merge pull request #201 from rcastagno/#194_merging_configfile_with_f…
Browse files Browse the repository at this point in the history
…ilter

#194 merging configfile with filter
  • Loading branch information
ryaneberly authored Oct 20, 2016
2 parents 920d663 + 74b49a7 commit e2f2036
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/.settings/
.gradle/**/*
/build
.idea/
26 changes: 24 additions & 2 deletions src/main/java/com/cflint/main/CFLintMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,10 @@ private void execute() throws IOException, TransformerException, JAXBException,
if (includeCodes != null && includeCodes.length > 0) {
filter.includeCode(includeCodes);
}
cflint.getBugs().setFilter(filter);

mergeConfigFileInFilter(filter);

cflint.getBugs().setFilter(filter);
for (final String scanfolder : folder) {
cflint.scan(scanfolder);
}
Expand Down Expand Up @@ -424,7 +427,26 @@ private void execute() throws IOException, TransformerException, JAXBException,
}
}

private void display(final String text) {
/**
* Merges included and excluded messages in the filter,
* as if you specified them in -includeRule and -excludeRule command line parameters
*
* @param filter
*/
private void mergeConfigFileInFilter(CFLintFilter filter)
{
CFLintConfig cfg = loadConfig(configfile);
for(PluginMessage message : cfg.getIncludes())
{
filter.includeCode(message.getCode());
}
for(PluginMessage message : cfg.getExcludes())
{
filter.excludeCode(message.getCode());
}
}

private void display(final String text) {
if (verbose) {
System.out.println(text);
}
Expand Down

0 comments on commit e2f2036

Please sign in to comment.