Skip to content

Commit 8734a8d

Browse files
fix for review comment
1 parent 2579dca commit 8734a8d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

joern-cli/frontends/swiftsrc2cpg/src/main/scala/io/joern/swiftsrc2cpg/passes/ConfigFileCreationPass.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ class ConfigFileCreationPass(cpg: Cpg, config: Config)
3535

3636
override def runOnPart(diffGraph: DiffGraphBuilder, file: Path): Unit = {
3737
val parseResult = if (isBinaryPlist(file)) {
38-
val header = s"<!--This has been generated from ${file.toAbsolutePath}-->\n"
39-
Try((PropertyListParser.parse(file.toFile).toXMLPropertyList, header))
38+
val sourceComment = s"\n<!--This file was generated from ${file.toAbsolutePath}-->"
39+
Try((PropertyListParser.parse(file.toFile).toXMLPropertyList, sourceComment))
4040
} else {
4141
Try((IOUtils.readEntireFile(file), ""))
4242
}
4343
parseResult match {
44-
case Success((content, header)) =>
45-
val configFileContent = s"$header$content"
44+
case Success((content, sourceComment)) =>
45+
val configFileContent = s"$content$sourceComment"
4646
val name = configFileName(file)
4747
val configNode = NewConfigFile().name(name).content(configFileContent)
4848
logger.debug(s"Adding config file $name")

joern-cli/frontends/swiftsrc2cpg/src/test/scala/io/joern/swiftsrc2cpg/passes/config/ConfigFileCreationPassTests.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ class ConfigFileCreationPassTests extends AnyFunSpec with Matchers {
6767
val node = diff.nodes.collectFirst { case n: NewConfigFile => n }.get
6868
node.name should (startWith("testbin") and endWith(".plist"))
6969
// binary should have been converted to XML content:
70-
node.content should (startWith("<!--This has been generated from") and endWith(Xml))
70+
node.content should startWith(Xml)
71+
// and the content should have a comment referencing the original file at the very end
72+
node.content.linesIterator.toList.last should startWith("<!--This file was generated from")
7173
}
7274
}
7375
}

0 commit comments

Comments
 (0)