SonarOpenCommunity / sonar-cxx

Function with cyclomatic complexity higher than threshold found JAVA-R1000
Anti-pattern
Minor
6 months ago6 months old
getNodeDescripton has a cyclomatic complexity of 24 with "High" risk
56    }
57  }
58
59  private String getNodeDescripton() {60    if (nodeType == CxxGrammarImpl.functionDefinition) {
61      return "function definition";
62    } else if (nodeType == CxxKeyword.IF
evalComplexAst has a cyclomatic complexity of 18 with "High" risk
253  }
254
255  @SuppressWarnings({"java:S131", "java:S1541", "java:S1142"})
256  private BigInteger evalComplexAst(AstNode exprAst) {257
258    // More complex expressions with more than one child
259    //
parseCommonCompilerOptions has a cyclomatic complexity of 55 with "Critical" risk
316    return values.contains(macro);
317  }
318
319  private void parseCommonCompilerOptions(String line, String fileElement) {320    // Always Defined //
321    //_INTEGRAL_MAX_BITS Reports the maximum size (in bits) for an integral type.
322    addMacro("_INTEGRAL_MAX_BITS=64", fileElement);
parseCommandObject has a cyclomatic complexity of 20 with "High" risk
120    }
121  }
122
123  private void parseCommandObject(JsonCompilationDatabaseCommandObject commandObject) {124
125    var defines = commandObject.getDefines();
126    var includes = commandObject.getIncludes();
consume has a cyclomatic complexity of 16 with "High" risk
 47  private int parentheseLevel = 0;   // parentheses / round brackets ( )
 48
 49  @Override
 50  public boolean consume(CodeReader code, Lexer output) { 51    var ch = (char) code.peek();
 52    var consumed = false;
 53