Skip to content

Commit 9c94d7f

Browse files
authored
upgrade to scala 2.13.4 (#1092)
* WIP scala 2.13.4 port. current issue: method with a single empty parameter list overrides method without any parameter list * .bsp to gitignore * don't fail for deprecation warnings temporarily * back to original version - getting deprecation warnings, but works * fix repl predef initialization * upgrade cask to resolve incompatible ujson version error * cleanup, implement parameter parsing (not quite sure...) * scalafmt * fix parameter passing to scripts * add test
1 parent c0f2cb8 commit 9c94d7f

12 files changed

Lines changed: 27 additions & 24 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ project/.bloop
1919
/target
2020
/foo.c
2121
/woo.c
22+
/.bsp
2223

2324
foo.c
2425
woo.c

build.sbt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ val overflowdbVersion = "1.28"
66
inThisBuild(
77
List(
88
organization := "io.shiftleft",
9-
/* n.b. skip 2.13.1, it has a regression https://github.com/scala/bug/issues/11754,
10-
* which is fixed in https://github.com/scala/scala/pull/8447, i.e. we can upgrade
11-
* to 2.13.2 once that's released */
12-
scalaVersion := "2.13.0",
9+
scalaVersion := "2.13.4",
1310
resolvers ++= Seq(
1411
Resolver.mavenLocal,
1512
Resolver.bintrayRepo("shiftleft", "maven"),
@@ -74,7 +71,7 @@ lazy val fuzzyc2cpgtests = Projects.fuzzyc2cpgtests
7471
ThisBuild/scalacOptions ++= Seq(
7572
"-deprecation",
7673
"-feature",
77-
"-Xfatal-warnings",
74+
// "-Xfatal-warnings", // TODO MP reenable
7875
"-language:implicitConversions",
7976
"-Ycache-macro-class-loader:last-modified",
8077
"-Ybackend-parallelism", "4")

console/build.sbt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ 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", // Fail the compilation if there are any warnings.
19+
// "-Xfatal-warnings", // TODO MP reenable // Fail the compilation if there are any warnings.
2020
"-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver.
2121
"-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error.
2222
"-Xlint:delayedinit-select", // Selecting member of DelayedInit.
2323
"-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element.
2424
"-Xlint:inaccessible", // Warn about inaccessible types in method signatures.
2525
"-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`.
2626
"-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id.
27-
"-Xlint:nullary-unit", // Warn when nullary methods return Unit.
2827
"-Xlint:option-implicit", // Option.apply used implicit view.
2928
"-Xlint:package-object-classes", // Class or object defined in package object.
3029
"-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds.
@@ -44,10 +43,10 @@ scalacOptions ++= Seq(
4443

4544
val ScoptVersion = "3.7.1"
4645
val BetterFilesVersion = "3.8.0"
47-
val CaskVersion = "0.6.7"
46+
val CaskVersion = "0.7.8"
4847
val CatsVersion = "2.0.0"
4948
val CirceVersion = "0.12.2"
50-
val AmmoniteVersion = "2.0.4"
49+
val AmmoniteVersion = "2.3.8-4-88785969"
5150
val ZeroturnaroundVersion = "1.13"
5251

5352
dependsOn(Projects.fuzzyc2cpg % Test)

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,10 @@ trait BridgeBase {
261261
private def runScript(scriptFile: Path, config: Config) = {
262262
val isEncryptedScript = scriptFile.ext == "enc"
263263
System.err.println(s"executing $scriptFile with params=${config.params}")
264-
val scriptArgs: Seq[(String, Option[String])] = {
265-
val commandArgs = config.command match {
266-
case Some(command) => Seq(command -> None)
267-
case _ => Nil
268-
}
269-
commandArgs ++ config.params.view.mapValues(Option.apply).toSeq
264+
val scriptArgs: Seq[String] = {
265+
val commandArgs = config.command.toList
266+
val parameterArgs = config.params.flatMap { case (key, value) => Seq(s"--$key", value) }
267+
commandArgs ++ parameterArgs
270268
}
271269
val actualScriptFile =
272270
if (isEncryptedScript) decryptedScript(scriptFile)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object Run {
2222
override val name = "custom"
2323
override def run(): Iterator[DiffGraph] = {
2424
implicit val diffGraph: DiffGraph.Builder = DiffGraph.newBuilder
25-
query.store
25+
query.store()
2626
Iterator(diffGraph.build())
2727
}
2828
}

console/src/main/scala/io/shiftleft/console/cpgcreation/CpgGenerator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abstract class CpgGenerator() {
3131
return None
3232
}
3333
val cmd = Seq[String](program) ++ arguments
34-
val exitValue = cmd.run.exitValue()
34+
val exitValue = cmd.run().exitValue()
3535
if (exitValue == 0) {
3636
Some(cmd.toString)
3737
} else {

console/src/main/scala/io/shiftleft/console/scan/ScanPass.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ class ScanPass(cpg: Cpg, queries: List[Query])
1313
override def runOnPart(query: Query): Iterator[DiffGraph] = {
1414
val diffGraph = DiffGraph.newBuilder
1515
query(cpg).foreach(diffGraph.addNode)
16-
Iterator(diffGraph.build)
16+
Iterator(diffGraph.build())
1717
}
1818
}

console/src/main/scala/io/shiftleft/console/scripting/AmmoniteExecutor.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@ trait AmmoniteExecutor {
3535
* @return The result of running the script.
3636
*/
3737
def runScript(scriptPath: Path, parameters: Map[String, String], bindings: IndexedSeq[Bind[_]]): IO[Any] = {
38+
val args: Seq[String] = parameters.flatMap { case (key, value) => Seq(s"--$key", value) }.toSeq
3839
for {
3940
replInstance <- IO(ammoniteMain.instantiateRepl(bindings))
4041
repl <- IO.fromEither(replInstance.left.map { case (err, _) => new RuntimeException(err.msg) })
4142
ammoniteResult <- IO {
42-
repl.interp.initializePredef()
43-
ammonite.main.Scripts.runScript(ammoniteMain.wd, os.Path(scriptPath), repl.interp, parameters.map {
44-
case (k, v) => k -> Some(v)
45-
}.toSeq)
43+
repl.initializePredef()
44+
ammonite.main.Scripts.runScript(ammoniteMain.wd, os.Path(scriptPath), repl.interp, args)
4645
}
4746
result <- ammoniteResult match {
4847
case Res.Success(res) => IO.pure(res)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@main def main(one: String, two: String) = {
2+
s"$one $two"
3+
}

console/src/test/scala/io/shiftleft/console/QueryDatabaseTests.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ object TestBundle extends QueryBundle {
1010
author = "an-author",
1111
title = "a-title",
1212
description = s"a-description $n",
13-
score = 2.0, traversal = { cpg =>
13+
score = 2.0,
14+
traversal = { cpg =>
1415
cpg.method
1516
}
1617
)

0 commit comments

Comments
 (0)