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
log() method incorrectly calculates the column number when Tabs are used #14820
Comments
In addition, see https://checkstyle.org/report_issue.html#How_to_report_a_bug.3F . |
When a case is provided, it will have to be examined if this issue is related to #14780 as both are javadocs. |
@rnveach , your reference is accurate. |
If this is a duplicate of #14780 then we need to close this issue. I can't argue against closing as too few details are given in this issue. #14780 isn't truly about tabs, so I don't see how we are calculating tabs incorrectly. All our If the method is expecting 1-base and we are giving it 0-base then that is the issue and that is how it connects. However, looking at that method's code it does appear to be 0-based as well. So I am not seeing the connection yet. |
This may be the issue, which is unrelated to #14780 .
It looks like it is saying tabs go up to a certain position and then stop. Meaning 2 spaces plus a tab stop at the same position as a tab alone. That does make sense as I have seen some tools do this. Javadoc:
@Zopsss Please try to create a case. |
Hey @rnveach Thanks for reviewing the issue. I have fixed the failing test case mentioned in this issue. I'll explain in detail why I opened this issue and what problem I was facing. I'll reply to your questions soon as it is already mid night here. Thanks again for showing your interest in this issue. |
I have updated the issue description explaining the problem I was facing in a more precise way I was passing the column number of leading asterisk with expanded tabs to the log() method. The So I was already passing the asterisk's column number with the expanded tabs to the
Here by At that time I wasn't sure what is the use of the So to fix this, I modified the Check implementation to pass the column number of the leading asterisk without tabs expanded to the The |
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words
Detected at: #14643 (comment)
I was working on the JavadocLeadingAsteriskAlignCheck. This new module checks if the leading asterisk is aligned properly in the javadoc comment or not. I had written a test case in which leading asterisks were preceded with Tabs. The Check is working fine, I used the getTabWidth() to get correct the tab size and calculate the column number. The Check is passing the correct column number of the leading asterisk to the log() method, so I expected all the test cases to pass. But the test which uses tabs was showing incorrect violations in its result.
This is my input file: InputJavadocLeadingAsteriskAlignTabs.java.
This is my test method: testTabs().
Below I have provided the Snapshot of the test case with debugger:
As you can see in the right side of the Snapshot, on line 59 there is a violation because the leading asterisk is incorrectly aligned on column number 5, it should be on column number 6 to make it aligned correctly. On the left side, it is visible that the
log()
method is receiving the asterisk's current column number which is 5 ( asteriskColumn ). Below is the test result:In the
unexpected
section of the test result, for line 59 it is expecting the asterisk's column number to be 8 but the actual column number passed to thelog()
method was 5. The test case always shows incorrect column number in theunexpected
section when Tabs are used even though thelog()
method is receiving the correct column numbers. After debugging thelog()
method, I found that the lengthExpandedTabs() method is calculating the column incorrectly that's why the test result shows incorrect column numbers. This is the same reason for other violations too.Describe what you expect in detail.
The test result is showing the incorrect column number in the
unexpected
section, the leading asterisk is not located at the column number that it is showing. So the lengthExpandedTabs() should be able to calculate the Tabs properly.The text was updated successfully, but these errors were encountered: