$ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<module name="TreeWalker">
<module name="CyclomaticComplexityCheck">
<property name="max" value="0" />
</module>
</module>
</module>
$ cat TestClass.java
package org.checkstyle.suppressionxpathfilter.cyclomaticcomplexity;
public class SuppressionXpathRegressionCyclomaticOne {
public void test(int a, int b) { //warn
if (a > b) {
} else {
}
}
$ java -jar checkstyle-8.10-all.jar -c config.xml TestClass.java
Starting audit...
[ERROR] TestClass.java:4:5: Cyclomatic Complexity is 2 (max allowed is 0). [CyclomaticComplexity]
Audit done.
Checkstyle ends with 1 errors.
$ java -jar checkstyle-8.10-all.jar -t TestClass.java | grep "4:5"
$ java -jar checkstyle-8.10-all.jar -t TestClass.java | grep "4:4"
|--METHOD_DEF -> METHOD_DEF [4:4]
| |--MODIFIERS -> MODIFIERS [4:4]
| | `--LITERAL_PUBLIC -> public [4:4]
First of all about different column numbers
The reason of this difference, that user messages consider tabs and start with 1, when AstTreeStringPrinter prints 0-based column numbers without calculating tabs.
So If you want numbers to be the same, we should pass tabwidth to AstTreeStringPrinter and little change one line and thats all
First of all about different column numbers
The reason of this difference, that user messages consider tabs and start with 1, when AstTreeStringPrinter prints 0-based column numbers without calculating tabs.
So If you want numbers to be the same, we should pass tabwidth to AstTreeStringPrinter and little change one line and thats all