diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/builder/Fluent.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/builder/Fluent.kt index 2ef61b6a2b..7beb6cf634 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/builder/Fluent.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/builder/Fluent.kt @@ -340,8 +340,7 @@ fun LanguageFrontend<*, *>.listComp( val holder = this@Holder if (holder is StatementHolder) { holder += node - } - if (holder is ArgumentHolder) { + } else if (holder is ArgumentHolder) { holder += node } diff --git a/cpg-core/src/test/kotlin/de/fraunhofer/aisec/cpg/graph/FluentTest.kt b/cpg-core/src/test/kotlin/de/fraunhofer/aisec/cpg/graph/FluentTest.kt index d9a23a1cf1..5bbb2fc77e 100644 --- a/cpg-core/src/test/kotlin/de/fraunhofer/aisec/cpg/graph/FluentTest.kt +++ b/cpg-core/src/test/kotlin/de/fraunhofer/aisec/cpg/graph/FluentTest.kt @@ -207,12 +207,7 @@ class FluentTest { compExpr { ref("i") ref("someIterable") - ref("i") gt - literal( - 5, - t("int") - ) // TODO: This line doesn't work as - // expected + ref("i") gt literal(5, t("int")) } } } @@ -240,7 +235,7 @@ class FluentTest { assertLocalName("i", compExpr.variable) assertIs(compExpr.iterable) assertLocalName("someIterable", compExpr.iterable) - // assertEquals(1, compExpr.predicates.size) + assertNotNull(compExpr.predicate) } @Test @@ -265,12 +260,7 @@ class FluentTest { compExpr { this.variable = declare { variable("i") } ref("someIterable") - ref("i") gt - literal( - 5, - t("int") - ) // TODO: This line doesn't work as - // expected + ref("i") gt literal(5, t("int")) } } } @@ -299,7 +289,7 @@ class FluentTest { assertLocalName("i", variableDecl.singleDeclaration) assertIs(compExpr.iterable) assertLocalName("someIterable", compExpr.iterable) - // assertEquals(1, compExpr.predicates.size) + assertNotNull(compExpr.predicate) } @Test @@ -327,12 +317,7 @@ class FluentTest { variable("y") } ref("someIterable") - ref("i") gt - literal( - 5, - t("int") - ) // TODO: This line doesn't work as - // expected + ref("i") gt literal(5, t("int")) } } } @@ -362,6 +347,6 @@ class FluentTest { assertLocalName("y", variableDecl.declarations[1]) assertIs(compExpr.iterable) assertLocalName("someIterable", compExpr.iterable) - // assertEquals(1, compExpr.predicates.size) + assertNotNull(compExpr.predicate) } }