Due to the fact that in the past in many IDEs and code editors the position of the first symbol in the line was 0, we have this hack in DetailAST:
// expect columns to start @ 0
columnNo = tok.getColumn() - 1;
Nowadays, in most popular IDEs (IntelliJ IDEA, Eclipse, sublime, VS Code, gedit) the first symbol has 1st position. The log method of AbstractCheck has a special hack to avoid confusion in the Checkstyle output:
final int col = 1 + CommonUtils.lengthExpandedTabs(
getLines()[lineNo - 1], colNo, tabWidth);
We always increment column number at list by 1. Tab expansion is another story, and it is OK.
That is why we need to consider that the first character starts on the 1st position too.
The fix will lead too the big regression.
- We need to remove
-1 from DetailAST
- We need to remove
+1 from AbstractCheck#log
- We should fix all UTs. Special attention to each failing UT, some checks violations may become confusing.
- The regression report for all failing checks has to be generated to prove that at least the number of violations will not be decreased. So the number of violations before and after fix should be equal.
Due to the fact that in the past in many IDEs and code editors the position of the first symbol in the line was 0, we have this hack in DetailAST:
Nowadays, in most popular IDEs (IntelliJ IDEA, Eclipse, sublime, VS Code, gedit) the first symbol has 1st position. The log method of AbstractCheck has a special hack to avoid confusion in the Checkstyle output:
We always increment column number at list by 1. Tab expansion is another story, and it is OK.
That is why we need to consider that the first character starts on the 1st position too.
The fix will lead too the big regression.
-1from DetailAST+1from AbstractCheck#log