-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Indentation incorrect level for chained method with bracket on new line #6210
Comments
@ati90ati Please give us full code and configuration so we can reproduce issue without problem. |
Hey there. I made a github repo to demonstrate this. https://github.com/johndaniels/checkstyle-bug I tried to make the config and code as minimal as possible. Let me know if that's specific enough. |
Case from repo is:
|
Sorry about that. Thanks for putting it in the more proper format! |
Just poking the thread to see if there has been any updates. For those who just don't want to deal with the error (like me), well, Indentation is more a readability issue in Java than anything else. If it's going to clog up my list of errors, better to simply remove the module until the fix is released. You can do so by ctrl+f "Indentation", and removing that line and it's property name's from the xml file. EDIT - Finally got a chance to get started. I will post any progress or discoveries made here - #6210 (comment) |
@dalayach No updates or activity. Anyone is free to help with a fix. |
I will do my best. I'm still in school, so forgive me if it takes forever. EDIT - Discoveries and changes made will be posted here. EDIT 1 - I've already mentioned before that simply disabling the check will do the job. Another option that seems to work is the following.
I know this doesn't help much, but on my way to understanding and simplifying the problem, I figured this would help other people out. Again, it seems that whatever the problem is, it will likely go away as long as your chain of methods is changing the value of something via = sign. This also means that whatever rule that allows checkstyle to ignore when there is an equal sign vs. where there is not is probably the same rule we are going to use to fix the problem. EDIT 2 - I think I've identified the source. Still don't know WHAT the bug is, but I have a good idea where it is. If you download the source files, open up the source file folder and look at these files in this order (since the next files was called/extended by the file(s) before it)...
This should isolate the problem to only the relevant portions. EDIT 3 - just to be SURE I identified the source, I used grep to find all files (within the indentation directory) that contained
Based off of this, it's safe to assume that we should look at these files too if we want to kill this bug for good. Not to say the other files contain the bug, but that if they did, it would likely be because they are implemented similarly to the way that resulted in the bug listed in OP. No guarantees though. I should clarify though, the main focus is AbstractExpressionHandler.java. This edit is merely to say we likely won't be done after solving the issue in AbstractExpressionHandler.java. |
@dalayach , thanks a lot for desire to help, just do code changes and provide Pull request. We will guide you further. |
8.21 I have the some problems |
…d call Review fixes. Add some tests
…d call Review fixes. Add some tests
…d call. Add some tests
…d call. Add some tests
…d call. Add some tests
…d call. Add some tests
…d call. Rename package
…d call. Add some tests
…d call. Rename package
…d call. Add some tests
…d call. Rename package
…d call. Review fixes
…d call. Review fixes
…d call. Review fixes
…d call. Example incorrect isChainedMethodCallWrapped
Fix is merged. |
The fix in 8.29 works only if the first line does not contain method chaining. I know, the examples are horrible. Following snippets use This case is fine: Arrays.asList("a", "b", "c")
.stream()
.map(String::toUpperCase)
.forEach(
System.out::println
); In this case we get flashbacks from 8.28: Arrays.asList("a", "b", "c").stream()
.map(String::toUpperCase)
.forEach(
System.out::println
); Accepted formatting is: Arrays.asList("a", "b", "c").stream()
.map(String::toUpperCase)
.forEach(
System.out::println
); |
@vilppuvuorinen, please open new issue with all details. |
Hello,
https://checkstyle.org/config_misc.html#Indentation
I'm using checkstyle 8.14 and I have a problem with Indentation check.
For chained methods I expect that line 77 should start at level 16 but the checkstyle reports that it should start at 8.
Maybe a fix can be added for this. Or a different parameter if needed. Or some parameter to disable these kind of checks (tokens) and allow only indentation for others.
NOTE:
assertThat
is fromassertj-core
library.NOTE 2: at this moment because of this bug the Indentation check is completely unusable (because we even cannot disable this rparen check).
The text was updated successfully, but these errors were encountered: