-
-
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… #14150
Conversation
… in Java 14 switch expression
Github, generate report |
Let's get hanging PRs across the finish line before we begin review here: https://github.com/checkstyle/checkstyle/pulls/aayushRedhat |
Please review @nrmancuso @romani |
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.
ok to merge, report is good
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.
Nevermind, I thought this was a swap, but I see it is an addition.
As a note, no test case was ever added for #377 .
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.
Item:
package com.puppycrawl.tools.checkstyle.checks.coding.innerassignment; | ||
|
||
//non-compiled with javac: Compilable with Java14 | ||
public class InputInnerAssignmentWithEnhancedSwitch { |
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 add more test cases:
boolean flag;
void m1(final String operation) {
boolean innerFlag;
innerFlag = switch (operation) {
case "Y" -> flag = true; // expected violation
case "N" -> {
yield flag = false; // expected violation
}
default -> throw new UnsupportedOperationException();
};
}
void m2(final String operation) {
boolean innerFlag;
switch (operation) {
case "Y": flag = true; break; // should be ok
case "N": {
flag = false; // should be ok
break;
}
default: throw new UnsupportedOperationException();
}
}
void m3(final String operation) {
boolean innerFlag;
switch (operation) {
case "Y" -> flag = innerFlag = true; // expected violation
case "N" -> {
flag = innerFlag = false; // expected violation
}
default -> throw new UnsupportedOperationException();
}
}
@aayushRedHat ping |
Sorry @nrmancuso @romani for the delay in my PR. I was on Holidays, will start working tomorrow. |
We lost contact with PR author, anyone is welcome to pick this up and reuse the code here |
Related: #13086
Diff Regression config: https://gist.githubusercontent.com/aayushRedHat/7197864ed054dca9580c0cc8c441c1fd/raw/ae6d36be203f1228e0dbb013941c8a29ce6427b6/gistfile1.txt