Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality Python Tests #1734

Merged
merged 42 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
79fa1a9
Added `add(index, element)` for `UnwrappedEdgeList`
oxisto Sep 25, 2024
dc293e6
Added test case
oxisto Sep 25, 2024
715d360
Bump Kotlin to 2.0.20
maximiliankaul Sep 25, 2024
6bab814
Merge branch 'mk/kotlin_2_0_20' into mk/forLoopMultiVar
maximiliankaul Sep 25, 2024
441dca3
Handler: add get a random Name
maximiliankaul Sep 25, 2024
c606f56
implement multi vars in for loops
maximiliankaul Sep 25, 2024
6ef5616
enable uuid for the whole project
maximiliankaul Sep 25, 2024
a55d281
Merge branch 'mk/handlerGetRandom' into mk/forLoopMultiVar
maximiliankaul Sep 25, 2024
c32d155
Merge branch 'main' into mk/handlerGetRandom
oxisto Sep 25, 2024
73a53cd
move helper function to Name
maximiliankaul Sep 25, 2024
af74693
Merge branch 'mk/handlerGetRandom' into mk/forLoopMultiVar
maximiliankaul Sep 25, 2024
ef922eb
configure prefix and separator char
maximiliankaul Sep 25, 2024
b50985a
Merge branch 'mk/handlerGetRandom' into mk/forLoopMultiVar
maximiliankaul Sep 25, 2024
30a7d1f
use the helper function now located in Name
maximiliankaul Sep 25, 2024
2bade9f
rename to random
maximiliankaul Sep 25, 2024
523fec2
Merge branch 'mk/handlerGetRandom' into mk/forLoopMultiVar
maximiliankaul Sep 25, 2024
be4f90a
extract constant prefix string
maximiliankaul Sep 25, 2024
b19cea9
change declaration placement
maximiliankaul Sep 25, 2024
db257bd
Merge branch 'main' into mk/forLoopMultiVar
maximiliankaul Sep 25, 2024
5a4db8a
polishing the code
maximiliankaul Sep 25, 2024
d077122
doc++
maximiliankaul Sep 25, 2024
0b8c1b7
Merge remote-tracking branch 'origin/main' into mk/forLoopMultiVar
maximiliankaul Sep 25, 2024
ed00ede
Open a block and function scope for python functions
oxisto Sep 25, 2024
c102179
Merge branch 'python-function-scope' into mk/forLoopMultiVar
maximiliankaul Sep 26, 2024
a112459
Update cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/fr…
maximiliankaul Sep 26, 2024
fe073f1
Update cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/fr…
maximiliankaul Sep 26, 2024
d812822
Update cpg-language-python/src/test/kotlin/de/fraunhofer/aisec/cpg/fr…
maximiliankaul Sep 26, 2024
138ce62
code review
maximiliankaul Sep 26, 2024
090a617
fixed code quality problems
maximiliankaul Sep 26, 2024
64f3796
Replace first() with firstOrNull()
maximiliankaul Sep 26, 2024
ab5a10b
Merge branch 'mk/pythonCodeQualityProblemsFixed' into mk/pythonTestsF…
maximiliankaul Sep 26, 2024
75c0159
Merge branch 'main' into mk/pythonTestsFirstOrNull
maximiliankaul Sep 27, 2024
b639753
merge error
maximiliankaul Sep 27, 2024
a5b6a6c
merge error
maximiliankaul Sep 27, 2024
db89326
assertIs
maximiliankaul Sep 27, 2024
7ac679f
refersTo -> assertRefersTo
maximiliankaul Sep 27, 2024
6b8d807
code quality
maximiliankaul Sep 27, 2024
12777e8
assertInvokes
maximiliankaul Sep 27, 2024
0640490
assertInvokes
maximiliankaul Sep 27, 2024
a7ff213
replace more as? with assertIs
maximiliankaul Sep 27, 2024
2ba3f87
is to assertIs
maximiliankaul Sep 27, 2024
a1c067e
Merge branch 'main' into mk/pythonTestsFirstOrNull
oxisto Sep 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,20 @@ import de.fraunhofer.aisec.cpg.frontends.python.PythonLanguage.Companion.MODIFIE
import de.fraunhofer.aisec.cpg.graph.*
import de.fraunhofer.aisec.cpg.graph.Annotation
import de.fraunhofer.aisec.cpg.graph.declarations.*
import de.fraunhofer.aisec.cpg.graph.statements.*
import de.fraunhofer.aisec.cpg.graph.statements.expressions.*
import de.fraunhofer.aisec.cpg.graph.statements.AssertStatement
import de.fraunhofer.aisec.cpg.graph.statements.CatchClause
import de.fraunhofer.aisec.cpg.graph.statements.DeclarationStatement
import de.fraunhofer.aisec.cpg.graph.statements.ForEachStatement
import de.fraunhofer.aisec.cpg.graph.statements.Statement
import de.fraunhofer.aisec.cpg.graph.statements.TryStatement
import de.fraunhofer.aisec.cpg.graph.statements.expressions.AssignExpression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.Block
import de.fraunhofer.aisec.cpg.graph.statements.expressions.DeleteExpression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.Expression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.InitializerListExpression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.MemberExpression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.ProblemExpression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.Reference
import de.fraunhofer.aisec.cpg.graph.types.FunctionType
import de.fraunhofer.aisec.cpg.helpers.Util
import kotlin.collections.plusAssign
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,32 @@ class ExpressionHandlerTest {
}
assertNotNull(result)

val twoBoolOpCondition =
result.functions["twoBoolOp"]?.ifs?.singleOrNull()?.condition as? BinaryOperator
assertNotNull(twoBoolOpCondition)
val twoBoolOpCondition = result.functions["twoBoolOp"]?.ifs?.singleOrNull()?.condition
assertIs<BinaryOperator>(twoBoolOpCondition)
assertEquals("and", twoBoolOpCondition.operatorCode)
assertLocalName("a", twoBoolOpCondition.lhs)
assertLiteralValue(true, twoBoolOpCondition.rhs)

// We expect that lhs comes first in the EOG and then the rhs.
assertContains(twoBoolOpCondition.lhs.nextEOG, twoBoolOpCondition.rhs)

val threeBoolOpCondition =
result.functions["threeBoolOp"]?.ifs?.singleOrNull()?.condition as? BinaryOperator
assertNotNull(threeBoolOpCondition)
val threeBoolOpCondition = result.functions["threeBoolOp"]?.ifs?.singleOrNull()?.condition
assertIs<BinaryOperator>(threeBoolOpCondition)
assertEquals("and", threeBoolOpCondition.operatorCode)
assertLocalName("a", threeBoolOpCondition.lhs)
val threeBoolOpConditionRhs = threeBoolOpCondition.rhs as? BinaryOperator
assertNotNull(threeBoolOpConditionRhs)
val threeBoolOpConditionRhs = threeBoolOpCondition.rhs
assertIs<BinaryOperator>(threeBoolOpConditionRhs)
assertEquals("and", threeBoolOpConditionRhs.operatorCode)
assertLiteralValue(true, threeBoolOpConditionRhs.lhs)
assertLocalName("b", threeBoolOpConditionRhs.rhs)

val threeBoolOpNoBoolCondition =
result.functions["threeBoolOpNoBool"]?.ifs?.singleOrNull()?.condition as? BinaryOperator
assertNotNull(threeBoolOpNoBoolCondition)
result.functions["threeBoolOpNoBool"]?.ifs?.singleOrNull()?.condition
assertIs<BinaryOperator>(threeBoolOpNoBoolCondition)
assertEquals("and", threeBoolOpNoBoolCondition.operatorCode)
assertLocalName("a", threeBoolOpNoBoolCondition.lhs)
val threeBoolOpNoBoolConditionRhs = threeBoolOpNoBoolCondition.rhs as? BinaryOperator
assertNotNull(threeBoolOpNoBoolConditionRhs)
val threeBoolOpNoBoolConditionRhs = threeBoolOpNoBoolCondition.rhs
assertIs<BinaryOperator>(threeBoolOpNoBoolConditionRhs)
assertEquals("and", threeBoolOpNoBoolConditionRhs.operatorCode)
assertLiteralValue(true, threeBoolOpNoBoolConditionRhs.lhs)
assertLiteralValue("foo", threeBoolOpNoBoolConditionRhs.rhs)
Expand All @@ -82,12 +80,12 @@ class ExpressionHandlerTest {

val nestedBoolOpDifferentOp =
result.functions["nestedBoolOpDifferentOp"]?.ifs?.singleOrNull()?.condition
as? BinaryOperator
assertNotNull(nestedBoolOpDifferentOp)

assertIs<BinaryOperator>(nestedBoolOpDifferentOp)
assertEquals("or", nestedBoolOpDifferentOp.operatorCode)
assertLocalName("b", nestedBoolOpDifferentOp.rhs)
val nestedBoolOpDifferentOpLhs = nestedBoolOpDifferentOp.lhs as? BinaryOperator
assertNotNull(nestedBoolOpDifferentOpLhs)
val nestedBoolOpDifferentOpLhs = nestedBoolOpDifferentOp.lhs
assertIs<BinaryOperator>(nestedBoolOpDifferentOpLhs)
assertEquals("and", nestedBoolOpDifferentOpLhs.operatorCode)
assertLiteralValue(true, nestedBoolOpDifferentOpLhs.rhs)
assertLocalName("a", nestedBoolOpDifferentOpLhs.lhs)
Expand All @@ -100,12 +98,11 @@ class ExpressionHandlerTest {

val nestedBoolOpDifferentOp2 =
result.functions["nestedBoolOpDifferentOp2"]?.ifs?.singleOrNull()?.condition
as? BinaryOperator
assertNotNull(nestedBoolOpDifferentOp2)
assertIs<BinaryOperator>(nestedBoolOpDifferentOp2)
assertEquals("or", nestedBoolOpDifferentOp2.operatorCode)
assertLocalName("a", nestedBoolOpDifferentOp2.lhs)
val nestedBoolOpDifferentOp2Rhs = nestedBoolOpDifferentOp2.rhs as? BinaryOperator
assertNotNull(nestedBoolOpDifferentOp2Rhs)
val nestedBoolOpDifferentOp2Rhs = nestedBoolOpDifferentOp2.rhs
assertIs<BinaryOperator>(nestedBoolOpDifferentOp2Rhs)
assertEquals("and", nestedBoolOpDifferentOp2Rhs.operatorCode)
assertLiteralValue(true, nestedBoolOpDifferentOp2Rhs.lhs)
assertLocalName("b", nestedBoolOpDifferentOp2Rhs.rhs)
Expand Down
Loading
Loading