Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed Jan 7, 2017
1 parent 4c7b2c2 commit d3094dc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
37 changes: 14 additions & 23 deletions src/main/java/com/cflint/CFLint.java
Original file line number Diff line number Diff line change
Expand Up @@ -795,31 +795,22 @@ protected void reportRule(final Element elem, final Object expression, final Con
bldr.setExpression(elem.toString());
}
bldr.setRuleParameters(ruleInfo.getParameters());
if (expression instanceof CFExpression) {
BugInfo bugInfo = bldr.build((CFExpression) expression, elem);
final Token token = ((CFExpression) expression).getToken();

if (configuration.getIncludes().isEmpty()
|| configuration.getIncludes().contains(ruleInfo.getMessageByCode(msgcode))) {
if (configuration.getExcludes().isEmpty()
|| !configuration.getExcludes().contains(ruleInfo.getMessageByCode(msgcode))) {
if (!suppressed(bugInfo, token, context)) {
bugs.add(bugInfo);
}
if (configuration.includes(ruleInfo.getMessageByCode(msgcode))
&& !configuration.excludes(ruleInfo.getMessageByCode(msgcode))
){
if (expression instanceof CFExpression) {
BugInfo bugInfo = bldr.build((CFExpression) expression, elem);
final Token token = ((CFExpression) expression).getToken();
if (!suppressed(bugInfo, token, context)) {
bugs.add(bugInfo);
}
}
} else {
final BugInfo bug = bldr.build((CFParsedStatement) expression, elem);
if (msg.getLine() != null) {
bug.setLine(msg.getLine());
bug.setColumn(0);
}
if (configuration.getIncludes().isEmpty()
|| configuration.getIncludes().contains(ruleInfo.getMessageByCode(msgcode))) {
if (configuration.getExcludes().isEmpty()
|| !configuration.getExcludes().contains(ruleInfo.getMessageByCode(msgcode))) {
bugs.add(bug);
} else {
final BugInfo bug = bldr.build((CFParsedStatement) expression, elem);
if (msg.getLine() != null) {
bug.setLine(msg.getLine());
bug.setColumn(0);
}
bugs.add(bug);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cflint/config/CFLintConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public boolean includes(PluginMessage pluginMessage) {
}

public boolean excludes(PluginMessage pluginMessage) {
return (getExcludes().isEmpty() || !getExcludes().contains(pluginMessage));
return (!getExcludes().isEmpty() && getExcludes().contains(pluginMessage));
}

}
12 changes: 6 additions & 6 deletions src/test/java/com/cflint/config/TestCFLintConfig2.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

public class TestCFLintConfig2 {

final String config0 = "<config><includes code=\"ARG_VAR_CONFLICT\"/></config>";
final String config1 = "<config><includes code=\"COMPONENT_HINT_MISSING\"/></config>";
final String config2 = "<config><includes code=\"FUNCTION_HINT_MISSING\"/></config>";
final String config3 = "<config><includes code=\"ARG_HINT_MISSING\"/></config>";
final String sconfig0 = "<config><includes code=\"ARG_VAR_CONFLICT\"/></config>";
final String sconfig1 = "<config><includes code=\"COMPONENT_HINT_MISSING\"/></config>";
final String sconfig2 = "<config><includes code=\"FUNCTION_HINT_MISSING\"/></config>";
final String sconfig3 = "<config><includes code=\"ARG_HINT_MISSING\"/></config>";
@Test
public void test() throws Exception {
CFLintConfig config = com.cflint.config.ConfigUtils.unmarshal(config0, CFLintConfig.class);
CFLintConfig config1 = com.cflint.config.ConfigUtils.unmarshal(config0, CFLintConfig.class);
CFLintConfig config = com.cflint.config.ConfigUtils.unmarshal(sconfig0, CFLintConfig.class);
CFLintConfig config1 = com.cflint.config.ConfigUtils.unmarshal(sconfig1, CFLintConfig.class);

assertTrue(config.includes(new PluginMessage("ARG_VAR_CONFLICT")));
assertTrue(!config1.includes(new PluginMessage("ARG_VAR_CONFLICT")));
Expand Down

0 comments on commit d3094dc

Please sign in to comment.