Skip to content

Commit

Permalink
Issue #45: resolve AvoidInlineConditionals violations
Browse files Browse the repository at this point in the history
  • Loading branch information
romani committed Dec 25, 2016
1 parent 038753b commit cc915b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion checkstyle-sonar-plugin/config/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<suppress checks="InnerTypeLast" files=".*[\\/]src[\\/]main[\\/]"/>
<suppress checks="ArrayTrailingComma" files=".*[\\/]src[\\/]main[\\/]"/>
<suppress checks="ReturnCount" files=".*[\\/]src[\\/]main[\\/]"/>
<suppress checks="AvoidInlineConditionals" files=".*[\\/]src[\\/]main[\\/]"/>
<!--<suppress checks="AvoidInlineConditionals" files=".*[\\/]src[\\/]main[\\/]"/>-->
<suppress checks="ParameterName" files=".*[\\/]src[\\/]main[\\/]"/>

<suppress checks="LeftCurly" files=".*[\/]src[\/]test[\/]"/>
Expand Down
2 changes: 1 addition & 1 deletion checkstyle-sonar-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
<regex>
<pattern>org.sonar.plugins.checkstyle.CheckstyleAuditListener</pattern>
<branchRate>71</branchRate>
<lineRate>85</lineRate>
<lineRate>84</lineRate>
</regex>
<regex>
<pattern>org.sonar.plugins.checkstyle.CheckstyleConfiguration</pattern>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,17 @@ static String getMessage(AuditEvent event) {

@VisibleForTesting
static Integer getLineId(AuditEvent event) {
Integer result = null;
try {
int line = event.getLine();
// checkstyle returns 0 if there is no relation to a file content, but we use null
return line == 0 ? null : line;

if (line != 0) {
result = line;
}
} catch (Exception e) {
// checkstyle can throw a NullPointerException if the message is not set
return null;
}
return result;
}

/**
Expand Down

0 comments on commit cc915b2

Please sign in to comment.