-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 #14716: Fix the violation for modifiers wrapped in class def #14743
base: master
Are you sure you want to change the base?
Issue #14716: Fix the violation for modifiers wrapped in class def #14743
Conversation
We can test any potential scenario by adding that case to this file. Welcome to every suggestion. |
GitHub, generate report |
Report generation failed on phase "make_report", |
GitHub, generate report |
Above report is without openjdk17 (excluded since it is raising OutOfMemoryException) |
GitHub, generate report |
Generating a new report - including new popular open-source java repos. |
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.
items:
* @param node the node whose predecessors are to be checked. | ||
* @return true if node is preceded by an access modifier else false. | ||
*/ | ||
public static boolean isPrecededByAnyModifier(DetailAST node) { |
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 move it to src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/AbstractExpressionHandler.java
and test it by InputIndentationxxxxxxx.java
not a pure junit.
14e94b2
to
b638c94
Compare
&& (!TokenUtil.isOfType(modifier, | ||
TokenTypes.ANNOTATION, TokenTypes.STRICTFP, TokenTypes.LITERAL_STATIC) | ||
|| modifier.getPreviousSibling() == null | ||
|| !isPrecededByAnyModifier(modifier)) |
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 am continuing on the discussion at #14716 (comment) , I don't see how skipping specific tokens will serve a benefit. I don't think we should be reviewing this PR until we have some agreement here. There doesn't seem to be any clear reason why we are targeting these tokens. For example, why is static on this list and not public? How did we choose these specific tokens that we can explain to others.
Including @nrmancuso 's original comments, the input file in this PR needs to be vastly expanded.
We need a duplicate input file with all indentation at 0 showing the violations produced by bad code. Regression was done on good formatted code, so it will provide less value for this check in those terms. We should also do force strict as it will tell us exactly what indentation should be and when it is absolutely correct and not just meeting the min requirement.
We also need inputs where these tokens being skipped are completely alone on a line and are the first AST in the class def. All the current examples start with public, abstract, final which are not any of the tokens listed here.
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.
There doesn't seem to be any clear reason why we are targeting these tokens
Yep, my sentiments exactly.
@rnveach - I agree with you. We must rigorously see the regression of this patch on dirty codes elaborating as many scenario's as possible and then make a move. I will try and keep preparing samples of dirty codes with wrappings in class defs in as many possible ways as I think of and compare the regression reports. |
@kalpadiptyaroy, please find time to finish this PR |
Issue #14716: Fix the violation for modifiers wrapped in class definition
Diff Regression config: https://gist.githubusercontent.com/kalpadiptyaroy/187788693b6445aed065ce39a171c502/raw/cdb3feb926b07fd8c07df72997df9de4d38957ee/checks.xml
Diff Regression projects: https://gist.githubusercontent.com/kalpadiptyaroy/80471b85dff631584c7668ba773186c0/raw/69bc6e343a083698e61a0afd039a69cb0c1b28a2/my-projects-to-test-on.properties