-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Issue #15045: Add LITERAL_WHEN as decision point in CyclomaticComplex… #15341
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
Conversation
void testSwitch2(Object o) { // 1, function declaration | ||
switch (o) { // 2 switch | ||
case Integer i -> {} | ||
case Point(int x, int y) when (x == 0 && y == 0) -> {} // 3, when - 4, && | ||
case Point(int x, int y) when x == 0 -> {} // 5, when | ||
default -> {} | ||
} | ||
} |
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 not sure about it, but shouldn't it be more reasonable if we ignore everything inside the switch when switchBlockAsSingleDecisionPoint
is true? because basically, we should treat switch as a single decision point so considering when
and &&
as decision points and adding 1 to them is odd to me when this option is true
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 traditional switches in here with nested if
statements to allow us to compare how this check handles them
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, it got counted.
Lines 256 to 259 in 87d431a
if (switchBlockAsSingleDecisionPoint) { | |
if (ast.getType() != TokenTypes.LITERAL_CASE) { | |
incrementCurrentValue(BigInteger.ONE); | |
} |
looks like we only ignore case
when this option is true but anything else inside the switch will be counted
github, generate site |
github, generate report |
87d431a
to
410ca20
Compare
410ca20
to
784590f
Compare
…ticComplexityCheck
784590f
to
ecaace0
Compare
github, generate site |
closes #15045
Diff Regression config: https://gist.githubusercontent.com/mahfouz72/afd57aa6e51ca161b7927acd959e5211/raw/bdde1a4a901d1eca9e79c017dc8037fd989a020c/check.xml
Diff Regression patch config: https://gist.githubusercontent.com/mahfouz72/33967bf86e4a29cafa429771b0e95808/raw/6ec96ab6424c29e5c6ad0fb9d403cdda19054609/check_patch.xml