Skip to content

Commit

Permalink
refactor(model): Move the constant for the reference configuration file
Browse files Browse the repository at this point in the history
Put this next to other constants, and align to them by adding the "ORT_"
prefix.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jan 27, 2024
1 parent 1c88e81 commit 9146451
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cli/src/funTest/kotlin/OrtMainFunTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ import org.ossreviewtoolkit.model.OrtResult
import org.ossreviewtoolkit.model.config.OrtConfiguration
import org.ossreviewtoolkit.model.config.OrtConfigurationWrapper
import org.ossreviewtoolkit.model.config.ProviderPluginConfiguration
import org.ossreviewtoolkit.model.config.REFERENCE_CONFIG_FILENAME
import org.ossreviewtoolkit.model.readValue
import org.ossreviewtoolkit.model.toYaml
import org.ossreviewtoolkit.model.writeValue
import org.ossreviewtoolkit.utils.common.EnvironmentVariableFilter
import org.ossreviewtoolkit.utils.ort.ORT_REFERENCE_CONFIG_FILENAME
import org.ossreviewtoolkit.utils.test.getAssetFile
import org.ossreviewtoolkit.utils.test.matchExpectedResult
import org.ossreviewtoolkit.utils.test.patchActualResult
Expand Down Expand Up @@ -228,7 +228,7 @@ class OrtMainFunTest : StringSpec() {
}

"EnvironmentVariableFilter is correctly initialized" {
val referenceConfigFile = File("../model/src/main/resources/$REFERENCE_CONFIG_FILENAME").absolutePath
val referenceConfigFile = File("../model/src/main/resources/$ORT_REFERENCE_CONFIG_FILENAME").absolutePath

OrtMain().test(
"-c", referenceConfigFile,
Expand Down
5 changes: 0 additions & 5 deletions model/src/main/kotlin/config/OrtConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,3 @@ data class OrtConfiguration(
data class OrtConfigurationWrapper(
val ort: OrtConfiguration
)

/**
* The filename of the reference configuration file.
*/
const val REFERENCE_CONFIG_FILENAME = "reference.yml"
4 changes: 2 additions & 2 deletions model/src/test/kotlin/JsonSchemaTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import io.kotest.matchers.should

import java.io.File

import org.ossreviewtoolkit.model.config.REFERENCE_CONFIG_FILENAME
import org.ossreviewtoolkit.utils.ort.ORT_LICENSE_CLASSIFICATIONS_FILENAME
import org.ossreviewtoolkit.utils.ort.ORT_PACKAGE_CONFIGURATION_FILENAME
import org.ossreviewtoolkit.utils.ort.ORT_PACKAGE_CURATIONS_FILENAME
import org.ossreviewtoolkit.utils.ort.ORT_REFERENCE_CONFIG_FILENAME
import org.ossreviewtoolkit.utils.ort.ORT_REPO_CONFIG_FILENAME
import org.ossreviewtoolkit.utils.ort.ORT_RESOLUTIONS_FILENAME

Expand Down Expand Up @@ -88,7 +88,7 @@ class JsonSchemaTest : StringSpec({

"The embedded reference configuration validates successfully" {
val ortConfigurationSchema = File("../integrations/schemas/ort-configuration-schema.json").toURI()
val referenceConfigFile = File("src/main/resources/$REFERENCE_CONFIG_FILENAME").toJsonNode()
val referenceConfigFile = File("src/main/resources/$ORT_REFERENCE_CONFIG_FILENAME").toJsonNode()

val errors = schemaV7.getSchema(ortConfigurationSchema).validate(referenceConfigFile)

Expand Down
3 changes: 2 additions & 1 deletion model/src/test/kotlin/config/OrtConfigurationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ import java.lang.IllegalArgumentException
import org.ossreviewtoolkit.model.Severity
import org.ossreviewtoolkit.model.SourceCodeOrigin
import org.ossreviewtoolkit.utils.common.EnvironmentVariableFilter
import org.ossreviewtoolkit.utils.ort.ORT_REFERENCE_CONFIG_FILENAME
import org.ossreviewtoolkit.utils.test.shouldNotBeNull

class OrtConfigurationTest : WordSpec({
"OrtConfiguration" should {
"be deserializable from YAML" {
val refConfig = File("src/main/resources/$REFERENCE_CONFIG_FILENAME")
val refConfig = File("src/main/resources/$ORT_REFERENCE_CONFIG_FILENAME")
val ortConfig = OrtConfiguration.load(file = refConfig)

ortConfig.allowedProcessEnvironmentVariableNames should containExactlyInAnyOrder("PASSPORT", "USER_HOME")
Expand Down
3 changes: 2 additions & 1 deletion model/src/test/kotlin/config/ReporterConfigurationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import java.io.File

import org.ossreviewtoolkit.model.fromYaml
import org.ossreviewtoolkit.model.toYaml
import org.ossreviewtoolkit.utils.ort.ORT_REFERENCE_CONFIG_FILENAME
import org.ossreviewtoolkit.utils.test.shouldNotBeNull

class ReporterConfigurationTest : WordSpec({
Expand All @@ -42,7 +43,7 @@ class ReporterConfigurationTest : WordSpec({
* Load the ORT reference configuration and extract the reporter configuration.
*/
private fun loadReporterConfig(): ReporterConfiguration =
OrtConfiguration.load(file = File("src/main/resources/$REFERENCE_CONFIG_FILENAME")).reporter
OrtConfiguration.load(file = File("src/main/resources/$ORT_REFERENCE_CONFIG_FILENAME")).reporter

/**
* Perform a serialization round-trip of the given reporter [config] and return the result. This is used to check
Expand Down
3 changes: 2 additions & 1 deletion model/src/test/kotlin/config/ScannerConfigurationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ import java.io.File

import org.ossreviewtoolkit.model.readValue
import org.ossreviewtoolkit.model.writeValue
import org.ossreviewtoolkit.utils.ort.ORT_REFERENCE_CONFIG_FILENAME

class ScannerConfigurationTest : WordSpec({
"ScannerConfiguration" should {
"support a serialization round-trip via an ObjectMapper" {
val ortConfig = OrtConfiguration.load(file = File("src/main/resources/$REFERENCE_CONFIG_FILENAME"))
val ortConfig = OrtConfiguration.load(file = File("src/main/resources/$ORT_REFERENCE_CONFIG_FILENAME"))
val rereadOrtConfig = tempfile(null, ".yml").run {
writeValue(ortConfig)
readValue<OrtConfiguration>()
Expand Down
4 changes: 2 additions & 2 deletions plugins/commands/config/src/main/kotlin/ConfigCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import com.github.ajalt.clikt.parameters.types.file

import org.ossreviewtoolkit.model.config.OrtConfiguration
import org.ossreviewtoolkit.model.config.OrtConfigurationWrapper
import org.ossreviewtoolkit.model.config.REFERENCE_CONFIG_FILENAME
import org.ossreviewtoolkit.plugins.commands.api.OrtCommand
import org.ossreviewtoolkit.utils.common.collectMessages
import org.ossreviewtoolkit.utils.common.expandTilde
import org.ossreviewtoolkit.utils.ort.ORT_REFERENCE_CONFIG_FILENAME

class ConfigCommand : OrtCommand(
name = "config",
Expand Down Expand Up @@ -84,7 +84,7 @@ class ConfigCommand : OrtCommand(
if (showReference) {
echo("The reference configuration is:")
echo()
echo(javaClass.getResource("/$REFERENCE_CONFIG_FILENAME").readText())
echo(javaClass.getResource("/$ORT_REFERENCE_CONFIG_FILENAME").readText())
}

checkSyntax?.run {
Expand Down
5 changes: 5 additions & 0 deletions utils/ort/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ const val ORT_DATA_DIR_ENV_NAME = "ORT_DATA_DIR"
*/
const val ORT_CONFIG_FILENAME = "config.yml"

/**
* The filename of the reference configuration file.
*/
const val ORT_REFERENCE_CONFIG_FILENAME = "reference.yml"

/**
* The name of the ORT copyright garbage configuration file.
*/
Expand Down

0 comments on commit 9146451

Please sign in to comment.