Skip to content

Commit

Permalink
Upgrade ScanCode to the latest development version
Browse files Browse the repository at this point in the history
This includes a massive refactoring with lots of performance
improvements. For details see

aboutcode-org/scancode-toolkit#885
  • Loading branch information
sschuberth committed Feb 16, 2018
1 parent 258e956 commit 4519ccf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scanner/src/funTest/assets/scanners/scancode-toolkit
22 changes: 17 additions & 5 deletions scanner/src/main/kotlin/scanners/ScanCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ object ScanCode : Scanner() {
private const val OUTPUT_FORMAT = "json-pp"
private const val TIMEOUT = 300

private val DEFAULT_OPTIONS = listOf("--copyright", "--license", "--info", "--diag", "--only-findings",
"--strip-root")
private val DEFAULT_OPTIONS = listOf(
"--copyright",
"--license",
"--license-text",
"--info",
"--only-findings",
"--strip-root"
)

private val TIMEOUT_REGEX = Pattern.compile(
"ERROR: Processing interrupted: timeout after (?<timeout>\\d+) seconds. \\(File: .+\\)")
Expand All @@ -60,17 +66,23 @@ object ScanCode : Scanner() {
override fun scanPath(path: File, resultsFile: File): Result {
val options = DEFAULT_OPTIONS.toMutableList()
if (log.isEnabledFor(Level.DEBUG)) {
options.add("--license-diag")
options.add("--verbose")
}

val outputFormatOption = if (OUTPUT_FORMAT.startsWith("json")) {
"--$OUTPUT_FORMAT"
} else {
"--output-$OUTPUT_FORMAT"
}

val process = ProcessCapture(
scannerPath.absolutePath,
*options.toTypedArray(),
"--timeout", TIMEOUT.toString(),
"-n", Math.max(1, Runtime.getRuntime().availableProcessors() - 1).toString(),
"-f", OUTPUT_FORMAT,
"--processes", Math.max(1, Runtime.getRuntime().availableProcessors() - 1).toString(),
path.absolutePath,
resultsFile.absolutePath
outputFormatOption, resultsFile.absolutePath
)

if (process.stderr().isNotBlank()) {
Expand Down

0 comments on commit 4519ccf

Please sign in to comment.