Skip to content

Commit

Permalink
Issue checkstyle#13086: InnerAssignmentCheck failed for one line code…
Browse files Browse the repository at this point in the history
… in Java 14 switch expression
  • Loading branch information
shamithDI authored and sammy227799 committed May 27, 2023
1 parent b35c2e6 commit eecbeb9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
Expand Up @@ -150,6 +150,7 @@ public class InnerAssignmentCheck
TokenTypes.RESOURCE_SPECIFICATION,
},
{TokenTypes.EXPR, TokenTypes.LAMBDA},
{TokenTypes.EXPR, TokenTypes.SWITCH_RULE},
};

/**
Expand Down
Expand Up @@ -42,20 +42,20 @@ public void testIt() throws Exception {
"22:19: " + getCheckMessage(MSG_KEY),
"24:39: " + getCheckMessage(MSG_KEY),
"26:35: " + getCheckMessage(MSG_KEY),
"44:16: " + getCheckMessage(MSG_KEY),
"45:24: " + getCheckMessage(MSG_KEY),
"46:19: " + getCheckMessage(MSG_KEY),
"47:17: " + getCheckMessage(MSG_KEY),
"48:29: " + getCheckMessage(MSG_KEY),
"49:20: " + getCheckMessage(MSG_KEY),
"50:17: " + getCheckMessage(MSG_KEY),
"50:31: " + getCheckMessage(MSG_KEY),
"50:41: " + getCheckMessage(MSG_KEY),
"51:16: " + getCheckMessage(MSG_KEY),
"51:27: " + getCheckMessage(MSG_KEY),
"52:32: " + getCheckMessage(MSG_KEY),
"92:19: " + getCheckMessage(MSG_KEY),
"181:22: " + getCheckMessage(MSG_KEY),
"58:16: " + getCheckMessage(MSG_KEY),
"59:24: " + getCheckMessage(MSG_KEY),
"60:19: " + getCheckMessage(MSG_KEY),
"61:17: " + getCheckMessage(MSG_KEY),
"62:29: " + getCheckMessage(MSG_KEY),
"63:20: " + getCheckMessage(MSG_KEY),
"64:17: " + getCheckMessage(MSG_KEY),
"64:31: " + getCheckMessage(MSG_KEY),
"64:41: " + getCheckMessage(MSG_KEY),
"65:16: " + getCheckMessage(MSG_KEY),
"65:27: " + getCheckMessage(MSG_KEY),
"66:32: " + getCheckMessage(MSG_KEY),
"106:19: " + getCheckMessage(MSG_KEY),
"195:22: " + getCheckMessage(MSG_KEY)
};
verifyWithInlineConfigParser(
getPath("InputInnerAssignment.java"), expected);
Expand Down
Expand Up @@ -33,6 +33,20 @@ void innerAssignments()
}
}

public void expressionCanHaveParentSwitchCaseIssue13086()
{
// inner assignment should not flag an assignment expressions in a switch case
boolean flag = false;
String operation = "Y";
switch (operation)
{
case "Y" :
flag = true; // Allowed
break;
default : break;
}
}

public void demoBug1195047Comment3()
{
// inner assignment should flag all assignments to b or bb but none of those to i or j
Expand Down

0 comments on commit eecbeb9

Please sign in to comment.