Skip to content

Commit

Permalink
fix(typescript): fix key issues for scan
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 17, 2022
1 parent ef068f5 commit feac320
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,5 +345,24 @@ class Person(val name: String) : Human {
}
}
}

@Test
fun `should correct field bug`() {
val codeContainer = analyse("""
@Repository
class RedundancyRepositoryImpl(val jdbi: Jdbi) : RedundancyRepository {
private val table = "select sum(1) sum, m.clzname as name, m.module as module " +
"from code_method m, code_class c, method_access ma, code_class_access ca " +
"where ca.class_id=c.id and ca.is_interface = false and ca.is_abstract = false " +
"and ma.method_id = m.id and m.name not like '%${'$'}%'" +
"and m.name != '<clinit>' and m.name != 'main' and m.name != '<init>'" +
"and m.name != 'toString' and m.name != 'equals' and m.name != 'hashCode' and m.name != 'clone'" +
"and m.clzname = c.name and c.module=m.module and c.is_thirdparty = false and c.is_test != true " +
"and m.system_id=:system_id and c.system_id=:system_id and ma.system_id=:system_id " +
"group by m.clzname, m.module having sum = 1"
}
""".trimIndent())
assertEquals(2, codeContainer.DataStructures[0].Fields.size)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
}
"PropertyDeclarationExpressionContext" -> {
val ctx = childCtx as TypeScriptParser.PropertyDeclarationExpressionContext
val codeField = CodeField(TypeValue = ctx.propertyName().text)
val codeField = CodeField(TypeKey = ctx.propertyName().text)

val modifier = ctx.propertyMemberBase().text
if (modifier != "") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ import BadSmellThresholdTable from "./components/BadSmellThresholdTable";
val codeFile = TypeScriptAnalyser().analysis(personClassCode, "")
assertEquals(codeFile.DataStructures[0].Fields.size, 5)
assertEquals(codeFile.DataStructures[0].Fields[0].Modifiers[0], "public")
assertEquals(codeFile.DataStructures[0].Fields[0].TypeValue, "publicString")
assertEquals(codeFile.DataStructures[0].Fields[0].TypeKey, "publicString")
assertEquals(codeFile.DataStructures[0].Fields[0].TypeType, "string")
assertEquals(codeFile.DataStructures[0].Fields[1].TypeType, "string")
assertEquals(codeFile.DataStructures[0].Fields[4].Modifiers.size, 0)
Expand Down

0 comments on commit feac320

Please # to comment.