Skip to content

Commit

Permalink
refactor(evaluator): Rename a variable according to its type
Browse files Browse the repository at this point in the history
The scripts are URIs, not URLs, otherwise the `toURL()` call later on
would be superfluous.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Nov 17, 2023
1 parent 40630f4 commit f42b72d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions plugins/commands/evaluator/src/main/kotlin/EvaluatorCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ class EvaluatorCommand : OrtCommand(
).flag()

override fun run() {
val scriptUrls = mutableSetOf<URI>()
val scriptUris = mutableSetOf<URI>()

rulesFile.mapTo(scriptUrls) { it.toURI() }
rulesResource.mapTo(scriptUrls) { javaClass.getResource(it).toURI() }
rulesFile.mapTo(scriptUris) { it.toURI() }
rulesResource.mapTo(scriptUris) { javaClass.getResource(it).toURI() }

if (scriptUrls.isEmpty()) {
scriptUrls += ortConfigDirectory.resolve(ORT_EVALUATOR_RULES_FILENAME).toURI()
if (scriptUris.isEmpty()) {
scriptUris += ortConfigDirectory.resolve(ORT_EVALUATOR_RULES_FILENAME).toURI()
}

val configurationFiles = listOfNotNull(
Expand Down Expand Up @@ -235,7 +235,7 @@ class EvaluatorCommand : OrtCommand(

var allChecksSucceeded = true

scriptUrls.forEach {
scriptUris.forEach {
if (evaluator.checkSyntax(it.toURL().readText())) {
echo("Syntax check for $it succeeded.")
} else {
Expand Down Expand Up @@ -310,11 +310,11 @@ class EvaluatorCommand : OrtCommand(
licenseClassificationsFile.takeIf { it.isFile }?.readValue<LicenseClassifications>().orEmpty()
val evaluator = Evaluator(ortResultInput, licenseInfoResolver, resolutionProvider, licenseClassifications)

val scripts = scriptUrls.map { it.toURL().readText() }
val scripts = scriptUris.map { it.toURL().readText() }
val evaluatorRun = evaluator.run(*scripts.toTypedArray())

val duration = with(evaluatorRun) { Duration.between(startTime, endTime).toKotlinDuration() }
echo("The evaluation of ${scriptUrls.size} script(s) took $duration.")
echo("The evaluation of ${scriptUris.size} script(s) took $duration.")

evaluatorRun.violations.forEach { violation ->
echo(violation.format())
Expand Down

0 comments on commit f42b72d

Please sign in to comment.