Skip to content

Commit c71dc53

Browse files
authored
upgrade codegen, fix most deprecation warnings (#1097)
* more * back to latest released codegen for now * more fixes, use latest released codegen * more fixes * more * fmt * fix remaining deprecation warnings * reenable fatal-warnings * Revert "reenable fatal-warnings" This reverts commit 3eddaec. * help/helpVerbose parens * reenable fatal-warnings, but somehow can't do that for console Might be a bug in scalac, but maybe I'm blind. Not super important right now, I left a comment for later * latest odb * properly disable Xfatal for console
1 parent ebb6232 commit c71dc53

21 files changed

Lines changed: 48 additions & 49 deletions

File tree

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name := "codepropertygraph"
22

33
// parsed by project/Versions.scala, updated by updateDependencies.sh
4-
val overflowdbVersion = "1.29"
4+
val overflowdbVersion = "1.30"
55

66
inThisBuild(
77
List(
@@ -71,7 +71,7 @@ lazy val fuzzyc2cpgtests = Projects.fuzzyc2cpgtests
7171
ThisBuild/scalacOptions ++= Seq(
7272
"-deprecation",
7373
"-feature",
74-
// "-Xfatal-warnings", // TODO MP reenable
74+
"-Xfatal-warnings",
7575
"-language:implicitConversions",
7676
"-Ycache-macro-class-loader:last-modified",
7777
"-Ybackend-parallelism", "4")

console/build.sbt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ scalacOptions ++= Seq(
1616
"-language:implicitConversions", // Allow definition of implicit functions called views
1717
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
1818
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
19-
// "-Xfatal-warnings", // TODO MP reenable // Fail the compilation if there are any warnings.
2019
"-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver.
2120
"-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error.
2221
"-Xlint:delayedinit-select", // Selecting member of DelayedInit.
@@ -41,6 +40,9 @@ scalacOptions ++= Seq(
4140
"-Ywarn-unused:privates" // Warn if a private member is unused.
4241
)
4342

43+
// would love to reenable, but somehow StorageBackend.scala triggers a strange `[warn] method with a single empty parameter list overrides method without any parameter list` that doesn't make sense to me...
44+
scalacOptions -= "-Xfatal-warnings"
45+
4446
val ScoptVersion = "3.7.1"
4547
val BetterFilesVersion = "3.8.0"
4648
val CaskVersion = "0.7.8"

console/src/main/scala/io/shiftleft/console/PPrinter.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import pprint.{PPrinter, Renderer, Result, Tree, Truncated}
55

66
object pprinter {
77

8-
val AnsiEncodedRegexp = """\u001b\[[\d;]+m""".r
8+
val AnsiEncodedRegexp = "\u001b\\[[\\d;]+m".r
99
def isAnsiEncoded(s: String): Boolean =
1010
AnsiEncodedRegexp.findFirstIn(s).isDefined
1111

@@ -15,10 +15,10 @@ object pprinter {
1515
* */
1616
def fixForFansi(ansiEncoded: String): String =
1717
ansiEncoded
18-
.replaceAll("""\u001b\[m""", """\u001b[39m""") //encoding ends with [39m for fansi instead of [m
19-
.replaceAll("""\u001b\[0(\d)m""", """\u001b[$1m""") // `[01m` is encoded as `[1m` in fansi for all single digit numbers
20-
.replaceAll("""\u001b\[0?(\d+);0?(\d+)m""", """\u001b[$1m\u001b[$2m""") // `[01;34m` is encoded as `[1m[34m` in fansi
21-
.replaceAll("""\u001b\[[00]+;0?(\d+);0?(\d+);0?(\d+)m""", """\u001b[$1;$2;$3m""") // `[00;38;05;70m` is encoded as `[38;5;70m` in fansi - 8bit color encoding
18+
.replaceAll("\u001b\\[m", "\u001b[39m") //encoding ends with [39m for fansi instead of [m
19+
.replaceAll("\u001b\\[0(\\d)m", "\u001b[$1m") // `[01m` is encoded as `[1m` in fansi for all single digit numbers
20+
.replaceAll("\u001b\\[0?(\\d+);0?(\\d+)m", "\u001b[$1m\u001b[$2m") // `[01;34m` is encoded as `[1m[34m` in fansi
21+
.replaceAll("\u001b\\[[00]+;0?(\\d+);0?(\\d+);0?(\\d+)m", "\u001b[$1;$2;$3m") // `[00;38;05;70m` is encoded as `[38;5;70m` in fansi - 8bit color encoding
2222

2323
def create(original: PPrinter): PPrinter =
2424
new PPrinter(defaultHeight = 99999, additionalHandlers = myAdditionalHandlers(original)) {

console/src/test/scala/io/shiftleft/console/scripting/AmmoniteExecutorTest.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class AmmoniteExecutorTest extends AnyWordSpec with Matchers {
3434
"pass arguments to a script" in withExecutor { executor =>
3535
val script = getScriptPath("scripts/general/arguments-concatenate.sc")
3636

37-
executor.runScript(script, Map("one" -> "hello", "two" -> "world"), Cpg.emptyCpg).unsafeRunSync() shouldBe "hello world"
37+
executor
38+
.runScript(script, Map("one" -> "hello", "two" -> "world"), Cpg.emptyCpg)
39+
.unsafeRunSync() shouldBe "hello world"
3840
}
3941

4042
"execute multiple scripts" in withExecutor { executor =>

fuzzyc2cpg/src/test/scala/io/shiftleft/fuzzyc2cpg/passes/CfgCreationPassTests.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,7 @@ class CfgFixture(file1Code: String) {
483483
}
484484

485485
def succOf(code: String): Set[String] = {
486-
codeToNode(code)
487-
._cfgOut()
488-
.asScala
486+
codeToNode(code)._cfgOut.asScala
489487
.map(_.asInstanceOf[nodes.CfgNode])
490488
.toSet
491489
.map[String](_.code)

project/meta-build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
libraryDependencies ++= Seq(
22
"com.github.pathikrit" %% "better-files" % "3.8.0",
3-
"io.shiftleft" %% "overflowdb-codegen" % "1.39",
3+
"io.shiftleft" %% "overflowdb-codegen" % "1.44",
44
)
55

66
resolvers += Resolver.bintrayRepo("shiftleft", "maven")

semanticcpg/src/main/scala/io/shiftleft/semanticcpg/dotgenerator/CdgGenerator.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ class CdgGenerator extends CfgGenerator {
1010
override val edgeType: String = EdgeTypes.CDG
1111

1212
override def expand(v: nodes.StoredNode): Iterator[Edge] = {
13-
v._cdgOut()
14-
.asScala
13+
v._cdgOut.asScala
1514
.filter(_.isInstanceOf[nodes.StoredNode])
1615
.map(node => Edge(v, node, edgeType = edgeType))
1716
}

semanticcpg/src/main/scala/io/shiftleft/semanticcpg/dotgenerator/DotSerializer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ object DotSerializer {
8383
}
8484

8585
private def escape(str: String): String = {
86-
str.replaceAllLiterally("\"", "\\\"")
86+
str.replace("\"", "\\\"")
8787
}
8888

8989
private def graphEnd(sb: StringBuilder): String = {

semanticcpg/src/main/scala/io/shiftleft/semanticcpg/language/LocationCreator.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ object LocationCreator {
111111
methodRef.code,
112112
methodRef.label,
113113
methodRef.lineNumber,
114-
methodRef._methodViaContainsIn.next
114+
methodRef._methodViaContainsIn.next()
115115
)
116116
case source: nodes.Source =>
117117
apply(source.node)
@@ -138,7 +138,7 @@ object LocationCreator {
138138
val namespaceOption = for {
139139
tpe <- typeOption
140140
namespaceBlock <- tpe._namespaceBlockViaAstIn
141-
namespace <- namespaceBlock._namespaceViaRefOut.nextOption
141+
namespace <- namespaceBlock._namespaceViaRefOut.nextOption()
142142
} yield namespace.name
143143
val namespaceName = namespaceOption.getOrElse("")
144144

@@ -162,7 +162,7 @@ object LocationCreator {
162162

163163
@tailrec
164164
private def findVertex(node: nodes.StoredNode, instanceCheck: nodes.StoredNode => Boolean): Option[nodes.StoredNode] =
165-
node._astIn.nextOption match {
165+
node._astIn.nextOption() match {
166166
case Some(head) if instanceCheck(head) => Some(head)
167167
case Some(head) => findVertex(head, instanceCheck)
168168
case None => None

semanticcpg/src/main/scala/io/shiftleft/semanticcpg/language/NewNodeSteps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait HasStoreMethod {
1111
class NewNodeSteps[A <: NewNode](val traversal: Traversal[A]) extends HasStoreMethod {
1212

1313
override def store()(implicit diffBuilder: DiffGraph.Builder): Unit =
14-
traversal.sideEffect(storeRecursively).iterate
14+
traversal.sideEffect(storeRecursively).iterate()
1515

1616
private def storeRecursively(newNode: NewNode)(implicit diffBuilder: DiffGraph.Builder): Unit = {
1717
diffBuilder.addNode(newNode)

0 commit comments

Comments
 (0)