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

[java] Cyclo metric should count conditions of for statements correctly #1483

oowekyala opened this Issue Nov 27, 2018 · 1 comment


None yet
2 participants
Copy link

oowekyala commented Nov 27, 2018


           class Foo {
                private static int compareImports(String import1, String import2) {
                    for (int i = 0; i != import1Tokens.length && i != import2Tokens.length; i++) {

The current implementation counts the complexity of the expression in the initializer int i = 0 instead of the boolean expression:

int boolCompFor = CycloMetric.booleanExpressionComplexity(node.getFirstDescendantOfType(ASTExpression.class));

@oowekyala oowekyala added this to the 6.10.0 milestone Nov 27, 2018

oowekyala added a commit to oowekyala/pmd that referenced this issue Nov 27, 2018


This comment has been minimized.

Copy link

adangel commented Nov 28, 2018

Ah, I see: The fix is to use node.getFirstChildOfType(ASTExpression.class) instead of getFirstDescendantOfType.... Just for reference: This is now handled in ASTForStatement.getGuardExpressionNode().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment