Skip to content

Commit

Permalink
Revert "refactor(scancode): Disregard the output format in scanner co…
Browse files Browse the repository at this point in the history
…nfiguration"

This reverts commit a8d6171.

While the change itself made sense, it breaks the matching with existing
scan results that still contain the `--json-pp` option. This means that
all stored `ScanCode` results cannot be used anymore.

As there is no way to fix this in the user configuration, revert the
change until a better solution is found.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Feb 2, 2024
1 parent 89b6325 commit 4661582
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion plugins/scanners/scancode/src/main/kotlin/ScanCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class ScanCode internal constructor(
const val SCANNER_NAME = "ScanCode"

private const val LICENSE_REFERENCES_OPTION_VERSION = "32.0.0"
private const val OUTPUT_FORMAT_OPTION = "--json-pp"
}

class Factory : ScannerWrapperFactory<ScanCodeConfig>(SCANNER_NAME) {
Expand All @@ -101,6 +102,7 @@ class ScanCode internal constructor(
override val configuration by lazy {
buildList {
addAll(config.commandLine)
add(OUTPUT_FORMAT_OPTION)

// Add this in the style of a fake command line option for consistency with the above.
if (config.preferFileLicense) add("--prefer-file-license")
Expand Down Expand Up @@ -165,7 +167,7 @@ class ScanCode internal constructor(
command(),
*commandLineOptions.toTypedArray(),
// The output format option needs to directly precede the result file path.
"--json-pp", resultFile.absolutePath,
OUTPUT_FORMAT_OPTION, resultFile.absolutePath,
path.absolutePath
)
}
4 changes: 2 additions & 2 deletions plugins/scanners/scancode/src/test/kotlin/ScanCodeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ScanCodeTest : WordSpec({

"configuration" should {
"return the default values if the scanner configuration is empty" {
scanner.configuration shouldBe "--copyright --license --info --strip-root --timeout 300"
scanner.configuration shouldBe "--copyright --license --info --strip-root --timeout 300 --json-pp"
}

"return the non-config values from the scanner configuration" {
Expand All @@ -56,7 +56,7 @@ class ScanCodeTest : WordSpec({

val scannerWithConfig = ScanCode("ScanCode", config, ScannerWrapperConfig.EMPTY)

scannerWithConfig.configuration shouldBe "--command --line"
scannerWithConfig.configuration shouldBe "--command --line --json-pp"
}
}

Expand Down

0 comments on commit 4661582

Please sign in to comment.