Issue #19548: Fix IllegalTokenText in google_checks.xml to detect 2-d…#19549
Issue #19548: Fix IllegalTokenText in google_checks.xml to detect 2-d…#19549vivek-0509 wants to merge 1 commit intocheckstyle:masterfrom
Conversation
…detect 2-digit octal escapes
|
Github, generate report |
|
@romani ping |
1 similar comment
|
@romani ping |
stoyanK7
left a comment
There was a problem hiding this comment.
Issue and PR look solid 👍
One small comment:
| String r5 = "\\15"; // violation 'Consider using special escape sequence' | ||
| String r6 = "\\40"; // violation 'Consider using special escape sequence' | ||
| String r7 = "\\42"; // violation 'Consider using special escape sequence' | ||
| String r8 = "\\47"; // violation 'Consider using special escape sequence' |
There was a problem hiding this comment.
Probably a separate issue, but should sequences starting with \\ actually be flagged?
For example, "\\47" is just a literal backslash \ followed by 47, not the octal escape \47, since the backslash itself is escaped.
So I’d expect cases like "\\47" (and "\\11") not to be a violation.
Please let me know if I’m misunderstanding how this escaping thing works.
|
This is false positive please add to inputs: it might be different issue , but in way we do violation I do not understand what is wrong here add to our inputs this https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/b2b6a47_2026084240/reports/diff/openjdk25/index.html#A126 , I am not sure what is expected form of code here, please add fixed copy of this line, to clearly point on part that need fix. |
|
@stoyanK7 @romani In the openjdk case, The I can add the lookahead to fix the |
|
Thanks for the detailed response @vivek-0509
Is it too much of a change to fix this scenario in this PR? False positives can be problem for users so we should avoid introducing them. I'm in favor of fixing that here.
Even if it wouldn't eliminate all false positives, it should eliminate most, right? I'm in favor of adding a lookbehind. But in a separate issue/PR because this false positive has been present in the check before this PR. We are not introducing it. |
|
Sounds good, I agree with both points. |
Issue #19548:
The regex only detected 3-digit octal forms (e.g.
\012) but missed equivalent 2-digit forms (e.g.\12) for characters with special escape sequences per Google Java Style Guide §2.3.2, and JLS §3.10.7Fix: changed
0(10|11|...)to0?(10|11|...)making the leading zero optional. Added integration test coverage for all 8 two-digit octal escapes.Diff Regression config: https://gist.githubusercontent.com/vivek-0509/26f7dc0977fa0ecaf66e127eb4245194/raw/171fc84ff7037cad652da44dbd135f994a03e163/base_config.xml
Diff Regression patch config: https://gist.githubusercontent.com/vivek-0509/4076379193a16479693fc871ec0f1cd8/raw/e0cc1597cde728943ee64faec406b5310e512628/patch_config.xml