From b45310a107ecdbb14d57ba8c81950a058fe0e731 Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Wed, 22 Nov 2023 20:53:32 +0100 Subject: [PATCH] Added complexity and mermaid chart --- .../cpg/graph/declarations/FunctionDeclaration.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/declarations/FunctionDeclaration.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/declarations/FunctionDeclaration.kt index b27d2dd259..bf69a20c09 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/declarations/FunctionDeclaration.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/declarations/FunctionDeclaration.kt @@ -280,6 +280,17 @@ val Statement.cyclomaticComplexity: Int // add one for each branch (and include the children) stmt.caseExpression?.let { i += it.cyclomaticComplexity } } + is DoStatement -> { + // add one for the do statement (and include the children) + i += (stmt.statement?.cyclomaticComplexity ?: 0) + 1 + } + is GotoStatement -> { + // add one + i++ + } + is StatementHolder -> { + i += stmt.cyclomaticComplexity + } } }