From d6e8d1334cf0f08a084a97cf8e14deb4c76c8688 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 2089b147200..20b252e2c10 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 @@ -301,6 +301,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 + } } }