-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
lineWrappingIndentation
falsely detects incorrect indentation for text blocks
#15939
Comments
@xpple , please consider to use https://checkstyle.org/filters/suppressionxpathsinglefilter.html#SuppressionXpathSingleFilter
|
Check should completely skip indentation validation for all nodes under |
hi @romani ,I'm trying to debug the input. However I'm getting language level error : and it does not go away even after I have set level to 21 |
Idea should be using jdk11 Just exclude Input from sources to compile. FYI: Indentation module is most complicated , if see it is hard, do not hesitate to drop issue and help us with something else. |
@romani like you said, I made it skip |
Just FYI, ignoring the check for public class A {
private static final String EXAMPLE = """
Example string""";
} The following would not: public class A {
private static final String EXAMPLE = """
Example string"""; // violation 8 != 4
} The first nonwhitespace character of a text block determines the offset of the text block; in both cases the resulting string is the same. |
@mohitsatr, please make PR.
All should be skipped for now, as it is just big string value, all spacing is user content. Not a target of this Check for now. Some other Check should be created to handle content of text blocks. |
@xpple , do you see my point that this Check should avoid text blocks at all? |
I see now that this issue was closed, but I forgot to respond.
No, I don't. Notice that the following strings are equal: private static final String A = """
a
""";
private static final String B = """
a
"""; That is, |
### What changes were proposed in this pull request? This PR aims to upgrade `checkstyle` from 10.20.2 to 10.21.2. ### Why are the changes needed? To pick up bug fixes: - checkstyle-10.21.2 checkstyle/checkstyle#15939 - lineWrappingIndentation falsely detects incorrect indentation for text blocks checkstyle/checkstyle#16101 - ignoreFieldDeclaration property should have the highest priority in MagicNumberCheck - checkstyle-10.21.1 checkstyle/checkstyle#11374 - UnusedLocalVariable: False Positive when inner class has same field as variable Full release notes: - https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.21.2 - https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.21.1 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Manually by: ``` bash ./dev/lint-java ``` ### Was this patch authored or co-authored using generative AI tooling? No. Closes #49899 from wayneguow/checkstyle. Authored-by: Wei Guo <guow93@gmail.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
### What changes were proposed in this pull request? This PR aims to upgrade `checkstyle` from 10.20.2 to 10.21.2. ### Why are the changes needed? To pick up bug fixes: - checkstyle-10.21.2 checkstyle/checkstyle#15939 - lineWrappingIndentation falsely detects incorrect indentation for text blocks checkstyle/checkstyle#16101 - ignoreFieldDeclaration property should have the highest priority in MagicNumberCheck - checkstyle-10.21.1 checkstyle/checkstyle#11374 - UnusedLocalVariable: False Positive when inner class has same field as variable Full release notes: - https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.21.2 - https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.21.1 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Manually by: ``` bash ./dev/lint-java ``` ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#49899 from wayneguow/checkstyle. Authored-by: Wei Guo <guow93@gmail.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
I have read check documentation: https://checkstyle.sourceforge.io/checks/misc/indentation.html
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
For Windows users, please use
type
instead ofcat
and runin place of the last 2 commands above.
Describe what you expect in detail.
The indentation is correct, so no warning should be reported. Note that the warning can be suppressed by adding
@SuppressWarnings("checkstyle:indentation")
to the declaration, given thatSuppressWarningsFilter
is configured.It seems to me that Checkstyle wants the ending
"""
on a new line. This is not a notational request, though; it'd be a different string as an extra new line character would be added.See JEP 378 for more information on text blocks.
The text was updated successfully, but these errors were encountered: