Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#194 merging configfile with filter #201

Merged
merged 2 commits into from
Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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