-
-
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 #13086: InnerAssignmentCheck failed for one line code in Java 1… #13090
Issue #13086: InnerAssignmentCheck failed for one line code in Java 1… #13090
Conversation
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 regression diff report.
Example how to do this: #13085
full doc: https://github.com/checkstyle/contribution/tree/master/checkstyle-tester#report-generation
items:
src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheck.java
Show resolved
Hide resolved
GitHub, generate report |
ea81f62
to
7965389
Compare
@@ -33,6 +33,20 @@ void innerAssignments() | |||
} | |||
} | |||
|
|||
public void expressionCanHaveParentSwitchCaseIssue13086() |
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 do not extend existing inputs. We need to create a completely new test and test input using switch statements, switch expressions, with both switch rules and labeled block statements. You will need to create the new input in resources-noncompilable in order to support syntax greater than jdk11.
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.
Yes, please create new Input file, this input file is already too big.
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 in addition add test case from user, to be absolutely clear that user reported case is covered
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.
@nrmancuso @romani This issue also exists when I ran with Java 11, so should I simply create a new test file in src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/innerassignment
instead of adding it in resources-noncompilable
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.
No, we must include exact case from issue report.
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.
@Andromeda227799 always allow reviewers to resolve their items, please just reply to each with “done” or discussion if necessary.
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
@Andromeda227799 you have not supplied a configuration, so no report will be generated. Please read https://github.com/checkstyle/contribution/tree/master/checkstyle-tester#report-generation |
GitHub, generate report |
Report generation failed on phase "make_report", |
@romani could you help me with why this failed? |
@Andromeda227799 you can click into link provided by GitHub action to see point of failure, looks like your configuration is not valid. |
8c32701
to
dfbaccb
Compare
GitHub, generate report |
Report generation failed on phase "make_report", |
GitHub, generate report |
1 similar comment
GitHub, generate report |
Report generation failed on phase "make_report", |
GitHub, generate report |
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.
void method(final String operation) { | ||
boolean flag = false; | ||
switch (operation) { | ||
case "Y" -> flag = true; // ok |
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 remove trailing comment // ok
I know there are a lot of examples where we have them, but it is our mistake of past.
No // violation
means ok, so //ok
is just a noise.
… in Java 14 switch expression
dfbaccb
to
5ee4d93
Compare
@Andromeda227799 , please look at my request above to extend Inputs , thanks in advance. |
We lost some valid violations, example: We need to differentiate between assignment in switch expression (should be violation) and switch statements (should not be a violation). This should be expected behavior:
|
Is there any update or advancement regarding this issue? |
@Andromeda227799 do you plan to continue to work on this issue?
@pmensalt looks like we might have lost contact with the author of this PR, let's see if they respond. |
if no activity before 1 october , we will close PR and next contributor can reuse this code and complete update |
We have lost contact with contributor, anyone is welcome to reuse changes here to resolve issue. |
@nrmancuso "We need to differentiate between assignment in switch expression (should be violation) and switch statements (should not be a violation)." Regarding this can you guide me a little bit on how can we add these? We have added the Switch rule {TokenTypes.EXPR, TokenTypes.SWITCH_RULE}, but do i need to create new rule for the second condition that is final boolean result = switch (operation) { |
@AayushSaini101 let’s open a new PR, please leave comments in your PR with what you are struggling with |
Fixing Issue #13086 by allowing Expressions to have switch cases as parent AST
Diff Regression config: https://gist.githubusercontent.com/Andromeda227799/52c0c74faeb9ba9334955fc68b624e98/raw/8ff5e9484d8c48022d9817fd299a1c5b6b644e71/check.xml