diff --git a/cpg-analysis/src/test/kotlin/de/fraunhofer/aisec/cpg/analysis/SizeEvaluatorTest.kt b/cpg-analysis/src/test/kotlin/de/fraunhofer/aisec/cpg/analysis/SizeEvaluatorTest.kt index 1119c14a9e2..57d7f2eb08c 100644 --- a/cpg-analysis/src/test/kotlin/de/fraunhofer/aisec/cpg/analysis/SizeEvaluatorTest.kt +++ b/cpg-analysis/src/test/kotlin/de/fraunhofer/aisec/cpg/analysis/SizeEvaluatorTest.kt @@ -38,11 +38,11 @@ import de.fraunhofer.aisec.cpg.graph.statements.expressions.Block import de.fraunhofer.aisec.cpg.graph.statements.expressions.CallExpression import de.fraunhofer.aisec.cpg.graph.statements.expressions.SubscriptExpression import de.fraunhofer.aisec.cpg.testcases.ValueEvaluationTests -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.TestInstance import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull +import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.TestInstance @TestInstance(TestInstance.Lifecycle.PER_CLASS) class SizeEvaluatorTest { diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt index 4966676446e..0bef9e924f6 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt @@ -713,16 +713,17 @@ class ScopeManager : ScopeProvider { // this is a scoped call. we need to explicitly jump to that particular scope val scopes = filterScopes { (it is NameScope && it.name == scopeName) } - s = if (scopes.isEmpty()) { - Util.errorWithFileLocation( - node, - LOGGER, - "Could not find the scope $scopeName needed to resolve the call ${node.name}" - ) - scope - } else { - scopes[0] - } + s = + if (scopes.isEmpty()) { + Util.errorWithFileLocation( + node, + LOGGER, + "Could not find the scope $scopeName needed to resolve the call ${node.name}" + ) + scope + } else { + scopes[0] + } } return Pair(s, name) 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 e8e7342104b..c6ce90eb085 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 @@ -684,13 +684,11 @@ fun LanguageFrontend<*, *>.whileCondition(init: WhileStatement.() -> Expression) } /** -<<<<<<< HEAD - * Configures the [DoStatement.condition] in the Fluent Node DSL of the nearest -======= * <<<<<<< HEAD Configures the [DoStatement.condition] in the Fluent Node DSL of the nearest ->>>>>>> 96ea3b6b4 (Use FluentDSL in analysis module (#1311)) - * enclosing [DoStatement]. The [init] block can be used to create further sub-nodes as well as - * configuring the created node itself. + * ======= + * <<<<<<< HEAD Configures the [DoStatement.condition] in the Fluent Node DSL of the nearest >>>>>>> + * 96ea3b6b4 (Use FluentDSL in analysis module (#1311)) enclosing [DoStatement]. The [init] block + * can be used to create further sub-nodes as well as configuring the created node itself. */ context(DoStatement) @@ -699,16 +697,16 @@ fun LanguageFrontend<*, *>.whileCondition(init: DoStatement.() -> Expression): E } /** -<<<<<<< HEAD -======= + * <<<<<<< HEAD + * ======= * Creates a new [CompoundStatement] in the Fluent Node DSL and sets it to the * [IfStatement.thenStatement] of the nearest enclosing [IfStatement]. The [init] block can be used * to create further sub-nodes as well as configuring the created node itself. * ======= ->>>>>>> 96ea3b6b4 (Use FluentDSL in analysis module (#1311)) - * Creates a new [Block] in the Fluent Node DSL and sets it to the [IfStatement.thenStatement] of - * the nearest enclosing [IfStatement]. The [init] block can be used to create further sub-nodes as - * well as configuring the created node itself. >>>>>>> main + * >>>>>>> 96ea3b6b4 (Use FluentDSL in analysis module (#1311)) Creates a new [Block] in the Fluent + * Node DSL and sets it to the [IfStatement.thenStatement] of the nearest enclosing [IfStatement]. + * The [init] block can be used to create further sub-nodes as well as configuring the created node + * itself. >>>>>>> main */ context(IfStatement) @@ -770,21 +768,19 @@ fun LanguageFrontend<*, *>.loopBody(init: Block.() -> Unit): Block { } /** -<<<<<<< HEAD -<<<<<<< HEAD - * Creates a new [Block] in the Fluent Node DSL and sets it to the [SwitchStatement.statement] of - * the nearest enclosing [SwitchStatement]. The [init] block can be used to create further sub-nodes - * as well as configuring the created node itself. -======= - * Creates a new [BlockStatement] in the Fluent Node DSL and sets it to the + * <<<<<<< HEAD <<<<<<< HEAD Creates a new [Block] in the Fluent Node DSL and sets it to the * [SwitchStatement.statement] of the nearest enclosing [SwitchStatement]. The [init] block can be * used to create further sub-nodes as well as configuring the created node itself. ->>>>>>> 29ccee203 (Renaming nodes to be shorter and more consistent (#1303)) -======= + * ======= + * Creates a new [BlockStatement] in the Fluent Node DSL and sets it to the + * [SwitchStatement.statement] of the nearest enclosing [SwitchStatement]. The [init] block can be + * used to create further sub-nodes as well as configuring the created node itself. >>>>>>> + * 29ccee203 (Renaming nodes to be shorter and more consistent (#1303)) + * ======= * Creates a new [Block] in the Fluent Node DSL and sets it to the [SwitchStatement.statement] of * the nearest enclosing [SwitchStatement]. The [init] block can be used to create further sub-nodes - * as well as configuring the created node itself. ->>>>>>> 96ea3b6b4 (Use FluentDSL in analysis module (#1311)) + * as well as configuring the created node itself. >>>>>>> 96ea3b6b4 (Use FluentDSL in analysis + * module (#1311)) */ context(SwitchStatement) diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/SymbolResolver.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/SymbolResolver.kt index 92faeb95ba9..5a1ad279ba0 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/SymbolResolver.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/SymbolResolver.kt @@ -382,10 +382,7 @@ open class SymbolResolver(ctx: TranslationContext) : ComponentPass(ctx) { } // TODO(oxisto): Move to inference class - protected fun handleUnknownField( - base: Type, - ref: Reference - ): FieldDeclaration? { + protected fun handleUnknownField(base: Type, ref: Reference): FieldDeclaration? { val name = ref.name // unwrap a potential pointer-type @@ -753,7 +750,8 @@ open class SymbolResolver(ctx: TranslationContext) : ComponentPass(ctx) { constructorCallExpression: ConstructorCallExpression ) { constructorCallExpression.containingClass?.let { containingClass -> - val recordDeclaration = constructorCallExpression.objectType(containingClass).recordDeclaration + val recordDeclaration = + constructorCallExpression.objectType(containingClass).recordDeclaration val signature = constructorCallExpression.arguments.map { it.type } if (recordDeclaration != null) { val constructor = diff --git a/cpg-core/src/test/kotlin/de/fraunhofer/aisec/cpg/passes/DFGTest.kt b/cpg-core/src/test/kotlin/de/fraunhofer/aisec/cpg/passes/DFGTest.kt index cea52d663db..441ded7cbb2 100644 --- a/cpg-core/src/test/kotlin/de/fraunhofer/aisec/cpg/passes/DFGTest.kt +++ b/cpg-core/src/test/kotlin/de/fraunhofer/aisec/cpg/passes/DFGTest.kt @@ -372,7 +372,7 @@ class DFGTest { val literal4 = result.literals[{ it.value == 4 }] assertNotNull(literal4) - val a4 = b.prevEOG.first { it is Reference } + val a4 = ab.prevDFG.first { it is Reference } assertTrue(literal4.nextDFG.contains(a4)) assertEquals(1, ab.prevDFG.size) } diff --git a/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/JavaCallResolverHelper.kt b/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/JavaCallResolverHelper.kt index e96dac4ebab..1067931ad3f 100644 --- a/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/JavaCallResolverHelper.kt +++ b/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/JavaCallResolverHelper.kt @@ -46,8 +46,8 @@ class JavaCallResolverHelper { * JLS13 ยง15.12.1. * * This function basically sets the correct type of the [Reference] containing the "super" - * keyword. Afterwards, we can use the regular [SymbolResolver.resolveMemberCallee] to resolve - * the [MemberCallExpression]. + * keyword. Afterwards, we can use the regular [SymbolResolver.resolveMemberCallee] to + * resolve the [MemberCallExpression]. * * @param callee The callee of the call expression that needs to be adjusted * @param curClass The class containing the call