Issue #10924: Fix LeftCurly empty blocks after supplementary Unicode - #21506
Issue #10924: Fix LeftCurly empty blocks after supplementary Unicode#21506ishu7w wants to merge 1 commit into
Conversation
|
GitHub, generate report |
|
Report generation failed on phase make_report, |
arturict
left a comment
There was a problem hiding this comment.
Reproduced this against 14.1.0 first: with option=nl and tokens=METHOD_DEF, both 𝒜() {} and emoji() /* 😀 */ {} are reported while the ascii twin is not. On this branch they are silent.
I also diffed LeftCurly output between master and this branch over guava, commons-lang and spring-framework, in nl and in the default eol, and there is no difference at all (262k violations in nl).
| @@ -344,8 +345,8 @@ else if (!TokenUtil.areOnSameLine(startToken, brace)) { | |||
| * @param brace brace AST | |||
| * @param braceLine line content | |||
There was a problem hiding this comment.
These are code points now, not line content. Same in validateNewLinePosition and in the verifyBrace javadoc.
There was a problem hiding this comment.
Done in 6c7d3b6. Updated both braceLine parameter descriptions to say they contain code points of the line containing the brace, and clarified the verifyBrace Javadoc as well. Thanks for the review and independent regression checks.
6c7d3b6 to
4024055
Compare
|
Github, generate report for LeftCurly/all-examples-in-one |
|
@arturict , please always run diff testing on wild real projects, even update looks simple. Surprises are very frequent. |
|
understood, i will trigger the report before approving from now on, also on the small ones. |
|
Report for LeftCurly/all-examples-in-one: |
|
Why this violation is disappearing? |
|
all three are an empty columnNo counts code points, but master does |
4024055 to
0dc3894
Compare
|
@ishu7w , please respond to my question |
|
@romani Sorry for the delayed response. The disappearing violations are false positives for empty The AST column counts Unicode code points, while The fix uses code-point indexing consistently, so the empty block is recognized correctly and the false positive disappears. The equivalent code without the emoji already produces no violation. |
Issue: #10924
With
LeftCurlyconfigured withoption=NLandtokens=METHOD_DEF,void 𝒜() {}andvoid emoji() /* 😀 */ {}incorrectly report brace-placement violations, whilevoid ascii() {}is accepted. The check uses a Unicode code-point AST column to index a UTF-16 String, so supplementary characters prevent recognition of the adjacent{}exemption.Use
getLineCodePointsandCodePointUtil.hasWhitespaceBeforefor the brace line. Add regression cases for a supplementary method name and an emoji comment, an ASCII control, and a nonempty Unicode method that must still report a violation. This addresses only the LeftCurly portion of the umbrella issue.Validation: the new regression test failed before the production change with two unexpected violations. After the fix, Java 21
mvn -B -ntp clean verifypassed, including all 50 LeftCurly tests, 6,788 unit/example tests (2 skipped), 1,347 integration tests, and all configured quality checks.Diff Regression config: https://gist.github.com/ishu7w/1900fa70b1807fd559f0f1423101ac51/raw/a6db845a813d122061e4861f2585de9b964e6b3d/left-curly-unicode.xml
AI assistance: Codex investigated the bug, prepared the fix and regression test, ran local validation, and drafted this description.