Skip to content

Commit

Permalink
Update scalafmt-core to 3.7.3 (joernio#2441)
Browse files Browse the repository at this point in the history
* Update scalafmt-core to 3.7.3

* Reformat with scalafmt 3.7.3

Executed command: scalafmt --non-interactive

* Add 'Reformat with scalafmt 3.7.3' to .git-blame-ignore-revs

* Revert commit(s) 3377ecd, 431350b, e2ba09c

* Update scalafmt-core to 3.7.3

* Reformat with scalafmt 3.7.3

Executed command: scalafmt --non-interactive

* Add 'Reformat with scalafmt 3.7.3' to .git-blame-ignore-revs
  • Loading branch information
scala-steward authored Apr 20, 2023
1 parent f9a2d39 commit 3e743c3
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ ad7116e128cd8d2b3d42fdd6168ed719a1578b52

# Scala Steward: Reformat with scalafmt 3.7.1
bf250ee518938384494e1cfe3627097d78b8096f

# Scala Steward: Reformat with scalafmt 3.7.3
9b86120d9611590c50f59280e3cde34b796f3562
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.7.2
version = 3.7.3
runner.dialect = scala213
preset = IntelliJ
maxColumn = 120
Expand Down
2 changes: 1 addition & 1 deletion console/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % Versions.scalatest % Test
)

Test/compile := (Test/compile).dependsOn((Projects.c2cpg/stage)).value
Test / compile := (Test / compile).dependsOn((Projects.c2cpg / stage)).value

scalacOptions ++= Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
Expand Down
4 changes: 2 additions & 2 deletions joern-cli/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % Versions.scalatest % Test
)

Test / compile := (Test/compile).dependsOn((Projects.c2cpg/stage), (Projects.jssrc2cpg/stage)).value
Test / fork := false
Test / compile := (Test / compile).dependsOn((Projects.c2cpg / stage), (Projects.jssrc2cpg / stage)).value
Test / fork := false

enablePlugins(UniversalPlugin)
enablePlugins(JavaAppPackaging)
Expand Down
12 changes: 6 additions & 6 deletions joern-cli/frontends/javasrc2cpg/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ packTestCode := {
import net.lingala.zip4j.model.enums.{CompressionLevel, CompressionMethod}
import java.nio.file.Paths

val pkgRoot = "io"
val testClassOutputPath = Paths.get("joern-cli", "frontends", "javasrc2cpg", "target", "scala-2.13", "test-classes")
val pkgRoot = "io"
val testClassOutputPath = Paths.get("joern-cli", "frontends", "javasrc2cpg", "target", "scala-2.13", "test-classes")
val relativeTestCodePath = Paths.get(pkgRoot, "joern", "javasrc2cpg", "jartypereader", "testcode")

File(testClassOutputPath.resolve(relativeTestCodePath)).list.filter(_.exists).foreach { testDir =>
val tmpDir = File.newTemporaryDirectory()
val tmpDir = File.newTemporaryDirectory()
val tmpDirWithCorrectPkgStruct = File(tmpDir.path.resolve(relativeTestCodePath)).createDirectoryIfNotExists()
testDir.copyToDirectory(tmpDirWithCorrectPkgStruct)
val testRootPath = tmpDir.path.resolve(pkgRoot)

val jarFilePath = testClassOutputPath.resolve(testDir.name ++ ".jar")
val jarFile = new ZipFile(jarFilePath.toAbsolutePath.toString)
val jarFilePath = testClassOutputPath.resolve(testDir.name ++ ".jar")
val jarFile = new ZipFile(jarFilePath.toAbsolutePath.toString)
val zipParameters = new ZipParameters()
zipParameters.setCompressionMethod(CompressionMethod.DEFLATE)
zipParameters.setCompressionLevel(CompressionLevel.NORMAL)
Expand All @@ -53,4 +53,4 @@ packTestCode := {
jarFile.addFolder(File(testRootPath).toJava)
}
}
packTestCode := packTestCode.triggeredBy(Test/compile).value
packTestCode := packTestCode.triggeredBy(Test / compile).value
5 changes: 2 additions & 3 deletions joern-cli/frontends/php2cpg/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ scalaVersion := "2.13.8"
crossScalaVersions := Seq("2.13.8", "3.2.2")

val phpParserVersion = "4.15.4-charfix.1"
val phpParserDlUrl = s"https://github.com/joernio/PHP-Parser/archive/refs/tags/$phpParserVersion.zip"
val phpParserDlUrl = s"https://github.com/joernio/PHP-Parser/archive/refs/tags/$phpParserVersion.zip"

dependsOn(Projects.dataflowengineoss, Projects.x2cpg % "compile->compile;test->test")

Expand All @@ -23,10 +23,9 @@ scalacOptions ++= Seq(
"-deprecation" // Emit warning and location for usages of deprecated APIs.
)


lazy val phpParseInstallTask = taskKey[Unit]("Install PHP-Parse using PHP Composer")
phpParseInstallTask := {
val phpBinDir = baseDirectory.value / "bin"
val phpBinDir = baseDirectory.value / "bin"
val phpParseDir = phpBinDir / "PHP-Parser"
if (!(phpParseDir / "bin").exists) {
IO.createDirectory(phpParseDir)
Expand Down
23 changes: 8 additions & 15 deletions joern-cli/frontends/rubysrc2cpg/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,21 @@ name := "rubysrc2cpg"
scalaVersion := "2.13.8"
crossScalaVersions := Seq("2.13.8", "3.2.2")

dependsOn(
Projects.dataflowengineoss,
Projects.x2cpg % "compile->compile;test->test"
)
dependsOn(Projects.dataflowengineoss, Projects.x2cpg % "compile->compile;test->test")

libraryDependencies ++= Seq(
"io.shiftleft" %% "codepropertygraph" % Versions.cpg,
"org.scalatest" %% "scalatest" % Versions.scalatest % Test,
"org.antlr" % "antlr4-runtime" % Versions.antlr
"io.shiftleft" %% "codepropertygraph" % Versions.cpg,
"org.scalatest" %% "scalatest" % Versions.scalatest % Test,
"org.antlr" % "antlr4-runtime" % Versions.antlr
)

scalacOptions ++= Seq(
"-deprecation" // Emit warning and location for usages of deprecated APIs.
)

enablePlugins(
JavaAppPackaging,
LauncherJarPlugin,
Antlr4Plugin
)
enablePlugins(JavaAppPackaging, LauncherJarPlugin, Antlr4Plugin)

Antlr4 / antlr4PackageName := Some("io.joern.rubysrc2cpg.parser")
Antlr4 / antlr4Version := Versions.antlr
Antlr4 / antlr4GenVisitor := true
Antlr4 / javaSource := (Compile / sourceManaged).value
Antlr4 / antlr4Version := Versions.antlr
Antlr4 / antlr4GenVisitor := true
Antlr4 / javaSource := (Compile / sourceManaged).value
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ class RubyLexerTests extends AnyFlatSpec with Matchers {
val lexer = new RubyLexer(CharStreams.fromString(code))
val syntaxErrorListener = new BaseErrorListener {
var errors = 0
override def syntaxError(recognizer: Recognizer[_, _], offendingSymbol: Any, line: Int, charPositionInLine: Int, msg: String, e: RecognitionException): Unit =
override def syntaxError(
recognizer: Recognizer[_, _],
offendingSymbol: Any,
line: Int,
charPositionInLine: Int,
msg: String,
e: RecognitionException
): Unit =
errors += 1
}
lexer.addErrorListener(syntaxErrorListener)
Expand Down Expand Up @@ -146,7 +153,12 @@ class RubyLexerTests extends AnyFlatSpec with Matchers {

"Non-interpolated, non-escaped double-quoted string literals" should "be recognized as such" in {
val eg = Seq("\"something\"", "\"x\n\"")
all(eg.map(tokenize)) shouldBe Seq(DOUBLE_QUOTED_STRING_START, DOUBLE_QUOTED_STRING_CHARACTER_SEQUENCE, DOUBLE_QUOTED_STRING_END, EOF)
all(eg.map(tokenize)) shouldBe Seq(
DOUBLE_QUOTED_STRING_START,
DOUBLE_QUOTED_STRING_CHARACTER_SEQUENCE,
DOUBLE_QUOTED_STRING_END,
EOF
)
}

"Double-quoted string literals containing identifier interpolations" should "be recognized as such" in {
Expand All @@ -156,7 +168,8 @@ class RubyLexerTests extends AnyFlatSpec with Matchers {
DOUBLE_QUOTED_STRING_CHARACTER_SEQUENCE,
INTERPOLATED_CHARACTER_SEQUENCE,
DOUBLE_QUOTED_STRING_END,
EOF)
EOF
)
}

"Double-quoted string literals containing escaped `#` characters" should "not be mistaken for interpolations" in {
Expand All @@ -171,7 +184,12 @@ class RubyLexerTests extends AnyFlatSpec with Matchers {

"Double-quoted string literals containing `#`" should "not be mistaken for interpolations" in {
val code = "\"x = #\""
tokenize(code) shouldBe Seq(DOUBLE_QUOTED_STRING_START, DOUBLE_QUOTED_STRING_CHARACTER_SEQUENCE, DOUBLE_QUOTED_STRING_END, EOF)
tokenize(code) shouldBe Seq(
DOUBLE_QUOTED_STRING_START,
DOUBLE_QUOTED_STRING_CHARACTER_SEQUENCE,
DOUBLE_QUOTED_STRING_END,
EOF
)
}

"Interpolated double-quoted string literal" should "be recognized as such" in {
Expand All @@ -185,7 +203,8 @@ class RubyLexerTests extends AnyFlatSpec with Matchers {
DECIMAL_INTEGER_LITERAL,
STRING_INTERPOLATION_END,
DOUBLE_QUOTED_STRING_END,
EOF)
EOF
)
}

"Recursively interpolated double-quoted string literal" should "be recognized as such" in {
Expand All @@ -204,12 +223,18 @@ class RubyLexerTests extends AnyFlatSpec with Matchers {
STRING_INTERPOLATION_END,
DOUBLE_QUOTED_STRING_CHARACTER_SEQUENCE,
DOUBLE_QUOTED_STRING_END,
EOF)
EOF
)
}

"Escaped `\"` in double-quoted string literal" should "not be mistaken for end of string" in {
val code = "\"x is \\\"4\\\"\""
tokenize(code) shouldBe Seq(DOUBLE_QUOTED_STRING_START, DOUBLE_QUOTED_STRING_CHARACTER_SEQUENCE, DOUBLE_QUOTED_STRING_END, EOF)
tokenize(code) shouldBe Seq(
DOUBLE_QUOTED_STRING_START,
DOUBLE_QUOTED_STRING_CHARACTER_SEQUENCE,
DOUBLE_QUOTED_STRING_END,
EOF
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class SymbolTests extends RubyParserAbstractTest {
}

"Operator-named symbols" should {
val symCaret = ":^"
val symEq2 = ":=="
val symCaret = ":^"
val symEq2 = ":=="
val symLRBrack = ":[]"

"be parsed as primary expressions" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MetaDataPassTests extends AnyWordSpec with Matchers {
"create a metadata node with correct language" in {
File.usingTemporaryDirectory("rubysrc2cpgTest") { dir =>
val config = Config(inputPath = dir.pathAsString, outputPath = dir.pathAsString)
val cpg = new RubySrc2Cpg().createCpg(config).get
val cpg = new RubySrc2Cpg().createCpg(config).get
cpg.metaData.language.l shouldBe List(Languages.RUBYSRC)
}
}
Expand Down

0 comments on commit 3e743c3

Please sign in to comment.