GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Issue #18614: Fix false positive in IndentationCheck for new operator by mdhamed238 · Pull Request #19684 · checkstyle/checkstyle Conversation
|
| // if our expression isn't first on the line, just use the start | ||
| // of the line | ||
| if (getLineStart(mainAst) == mainAst.getColumnNo()) { | ||
| if (isOnStartOfLine(mainAst)) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The fix is correct. getLineStart(mainAst) returns the visual (tab-expanded) column of the line's first non-whitespace character, while mainAst.getColumnNo() returns the raw token column (each tab counts as 1). With tab indentation these two numbers diverge even when new is at the start of the line, causing the condition to be unexpectedly false and falling into the else branch. Replacing it with isOnStartOfLine(mainAst) (defined as getLineStart(ast) == expandedTabsColumnNo(ast)) makes both sides use the same coordinate system, which is consistent with how checkIndentation() already checks the same token at line 61 of this same class.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| public void testCorrectNewInTryCatch() { //indent:4 exp:4 | ||
| try { //indent:8 exp:8 | ||
| client = new Inner( //indent:12 exp:12 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In testCorrectNewInTryCatch, new appears on the same line as client =, so it is NOT at the start of a line. isOnStartOfLine(mainAst) returns false for it, which means the fixed code path in getIndentImpl is never triggered by this method. The regression described in the issue title (false positive for new inside a try block) is not directly covered here. Consider adding a case where new is on its own line inside a try block, e.g.:
try { client = new Inner(null); //indent:16 exp:16 } catch (Exception e) { }
The existing testCorrectNewLineWrapped does exercise the fix, but a try-block-specific case would make the regression more traceable to the original issue.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks. I updated testCorrectNewInTryCatch so new is now on its own wrapped line inside the try block, which directly exercises the isOnStartOfLine(mainAst) path in getIndentImpl.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| checkConfig.addProperty("tabWidth", "4"); | ||
|
|
||
| final String fileName = getPath("InputIndentationTryCtorParams.java"); | ||
| final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The change to testTryBlockConstructorParameters (inlining fileName into the verifyWarns call) is unrelated to the bug fix and adds noise to the diff. It makes it harder to spot that this existing test was not modified for any functional reason. Please revert this change so the diff stays focused on the regression test.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I reverted that unrelated refactor and restored the original fileName local variable usage so the diff stays focused on the regression fix.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Thanks! @utafrali Updated the PR description to match the actual test file ( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
27608e2 to
81b299f
Compare
|
Github, generate report for Indentation/all-examples-in-one |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Report generation failed. Please check the logs for more details. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
please let us know if you have no time to finish it now, and somebody else can reuse your code to continue fix. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Apologies for the long silence on this PR. After pushing my last changes, all CI checks passed locally, but the report generation step failed, and I was unsure whether the issue was on my side or in the pipeline. I decided to wait for reviewer input before making further changes, and the PR ended up stalling longer than intended. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
rebase you PR on latest, and I will glance as they finish. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
81b299f to
3b9892e
Compare
|
@mdhamed238 , there is still conflict. Please read and watch playlist videos at Starting_Development. it explains how to deal with Github ,plase read and watch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
4e04fa1 to
6a473cc
Compare
|
Please rebase one more time, we merged update for Indentation few minutes ago. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
3d448ea to
d7b1fe9
Compare
d7b1fe9 to
bb0d354
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
issue is fixed by some other update as side effect, thanks a lot for test extension !
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.