Skip to content

Commit

Permalink
Track unused type declarations in usages slices
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu committed Dec 19, 2023
1 parent 3737e2c commit f0a3be2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name := "atom"
ThisBuild / organization := "io.appthreat"
ThisBuild / version := "1.7.4"
ThisBuild / version := "1.7.5"
ThisBuild / scalaVersion := "3.3.1"

val chenVersion = "1.0.9"
val chenVersion = "1.0.10"

lazy val atom = Projects.atom

Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.7
sbt.version=1.9.8
17 changes: 16 additions & 1 deletion src/main/scala/io/appthreat/atom/slicing/UsageSlicing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object UsageSlicing:
userDefTypes ++ routesAsUDT(atom)
)
else
ProgramUsageSlice(slices, userDefTypes)
ProgramUsageSlice(slices ++ unusedTypeDeclAsSlices(atom), userDefTypes)
end calculateUsageSlice

import io.shiftleft.semanticcpg.codedumper.CodeDumper.dump
Expand Down Expand Up @@ -122,6 +122,21 @@ object UsageSlicing:
)
)

private def unusedTypeDeclAsSlices(atom: Cpg): List[MethodUsageSlice] =
atom.typeDecl.annotation.filter(_.method.isEmpty).l.map(im =>
MethodUsageSlice(
code = if im.code.nonEmpty then im.code.replaceAll("\\s*", "") else "",
fullName = im.fullName,
signature = s"@${im.name}",
fileName = if im.file.nonEmpty then im.file.head.name else "",
slices = Seq[ObjectUsageSlice]().toSet,
lineNumber =
im.lineNumber.map(_.intValue()),
columnNumber =
im.columnNumber.map(_.intValue())
)
)

private def externalCalleesAsSlices(
atom: Cpg,
typeMap: TrieMap[String, String]
Expand Down
20 changes: 10 additions & 10 deletions wrapper/nodejs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions wrapper/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@appthreat/atom",
"version": "1.7.4",
"version": "1.7.5",
"description": "Create atom (⚛) representation for your application, packages and libraries",
"exports": "./index.js",
"type": "module",
Expand All @@ -14,7 +14,7 @@
"yargs": "^17.7.2"
},
"devDependencies": {
"eslint": "^8.55.0"
"eslint": "^8.56.0"
},
"bin": {
"atom": "./index.js",
Expand Down

0 comments on commit f0a3be2

Please sign in to comment.