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
Issue #5154: Incorrect indentation check for method preceded by annot… #5311
Conversation
@djydewang CI must pass. |
0cb05b4
to
2452596
Compare
Codecov Report
@@ Coverage Diff @@
## master #5311 +/- ##
======================================
Coverage 100% 100%
======================================
Files 296 296
Lines 16181 16182 +1
Branches 3698 3699 +1
======================================
+ Hits 16181 16182 +1
Continue to review full report at Codecov.
|
@rnveach |
Thanks. Old validation seems correct in this scenario. |
@rnveach |
all of them ok to my mind.
yes, previous behavior is more correct. Should be fixed. |
Actually, old validation didn't check the line:
And I except this:
I try to fix it and find it's a huge work~:( |
yes, Indentation is most complicated Check and full of bugs and .... . If regression report you have:
your PR fix issue #5154 but introduce new issue. I agree that case is weird and unlikely happen in real code. So users might not be affected and get more benefit from your fix. @rnveach , please share your ideas. |
2452596
to
0b05043
Compare
The regression report has updated. |
@@ -262,7 +262,8 @@ private void checkAnnotationIndentation(DetailAST atNode, | |||
if (isCurrentNodeCloseAnnotationAloneInLine | |||
|| node.getType() == TokenTypes.AT | |||
&& (parentNode.getParent().getType() == TokenTypes.MODIFIERS | |||
|| parentNode.getParent().getType() == TokenTypes.ANNOTATIONS)) { | |||
|| parentNode.getParent().getType() == TokenTypes.ANNOTATIONS) | |||
|| parentNode.getType() == TokenTypes.MODIFIERS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pietern all the other checks are verifying that we are validating the annotation, || parentNode.getType() == TokenTypes.MODIFIERS
by itself is just saying we should work if it is the modifiers, regardless of annotations or not.
The whole method is annotation related, shouldn't this check be verifying a annotation somehow? Isn't this validating more than it should?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't remember, it's been about 2 years since I last used checkstyle :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I pinged the wrong person. Don't know how auto-complete picked you. Sorry.
@djydewang I was directing this at you.
Right, but program shouldn't go to
No, you can see there is
And I excepted: The advice of romani:
So, I chose to check modifier at where you mentioned along old code logic. |
I am not saying your validation is wrong, I am saying that if your are checking non-annotations in an annotation only method then that is wrong. The method is only checking annotations and so bringing in other checks to that method will make the logic even more confusing.
If current node is a normal modifier like |
Right, I mean if we are going to check the normal node elsewhere, then we have to fix the issue I reported. |
0b05043
to
b8ff559
Compare
Right, I started out in this direction. I've found more and more Issues now, and if we're going to solve them we need to rewrite the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please generate new difference report for new changes.
I've found more and more Issues now
Please create new issues you have found. There are probably quite a few issues with indentation.
@@ -0,0 +1,18 @@ | |||
package com.puppycrawl.tools.checkstyle.checks.indentation.indentation; //indent:0 exp:0 | |||
|
|||
class InpuIndentationAnnotationIncorrect { //indent:0 exp:0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://djydewang.github.io/diffReport_Issue5154/checkstyle/xref/home/bbg/project/contribution/checkstyle-tester/repositories/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/annotationlocation/InputAnnotationLocationIncorrect.java.html#L7
Test case we mentioned before had annotation on top class. Can you replicate it in this input file. You may leave the annotation on the nested class as an additional case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
b8ff559
to
9982fe9
Compare
…d by annotation, with method parameter on separate line
37e60ff
to
8cacdd2
Compare
It's regression report.
|
regression is good |
You must give atleast 3 gigs of memory to indentation, especially if configuration is not optimized to specific project. |
…ation, with method parameter on separate line
Issue #5154.