Skip to content

Commit ab54d7a

Browse files
committed
chore(scanner): Remove the unused ScannerMatcher.create() function
This was only used in a test. Also remove related properties. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 34edf22 commit ab54d7a

File tree

2 files changed

+0
-78
lines changed

2 files changed

+0
-78
lines changed

scanner/src/main/kotlin/ScannerMatcher.kt

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.ossreviewtoolkit.scanner
2121

2222
import org.ossreviewtoolkit.model.ScannerDetails
23-
import org.ossreviewtoolkit.utils.common.Options
2423

2524
import org.semver4j.Semver
2625

@@ -111,50 +110,5 @@ data class ScannerMatcherConfig(
111110
) {
112111
companion object {
113112
val EMPTY = ScannerMatcherConfig(null, null, null, null)
114-
115-
/**
116-
* The name of the property defining the regular expression for the scanner name as part of [ScannerMatcher].
117-
* The [scanner details][ScannerDetails] of the corresponding scanner must match the criteria.
118-
*/
119-
internal const val PROP_CRITERIA_NAME = "regScannerName"
120-
121-
/**
122-
* The name of the property defining the minimum version of the scanner as part of [ScannerMatcher]. The
123-
* [scanner details][ScannerDetails] of the corresponding scanner must match the criteria.
124-
*/
125-
internal const val PROP_CRITERIA_MIN_VERSION = "minVersion"
126-
127-
/**
128-
* The name of the property defining the maximum version of the scanner as part of [ScannerMatcher]. The
129-
* [scanner details][ScannerDetails] of the corresponding scanner must match the criteria.
130-
*/
131-
internal const val PROP_CRITERIA_MAX_VERSION = "maxVersion"
132-
133-
/**
134-
* The name of the property defining the configuration of the scanner as part of [ScannerMatcher]. The
135-
* [scanner details][ScannerDetails] of the corresponding scanner must match the criteria.
136-
*/
137-
internal const val PROP_CRITERIA_CONFIGURATION = "configuration"
138-
139-
private val properties = listOf(
140-
PROP_CRITERIA_NAME, PROP_CRITERIA_MIN_VERSION, PROP_CRITERIA_MAX_VERSION, PROP_CRITERIA_CONFIGURATION
141-
)
142-
143-
/**
144-
* Create a [ScannerMatcherConfig] from the provided options. Return the created config and the options without
145-
* the properties that are used to configure the matcher.
146-
*/
147-
fun create(options: Options): Pair<ScannerMatcherConfig, Options> {
148-
val filteredOptions = options.filterKeys { it !in properties }
149-
150-
val matcherConfig = ScannerMatcherConfig(
151-
regScannerName = options[PROP_CRITERIA_NAME],
152-
minVersion = options[PROP_CRITERIA_MIN_VERSION],
153-
maxVersion = options[PROP_CRITERIA_MAX_VERSION],
154-
configuration = options[PROP_CRITERIA_CONFIGURATION]
155-
)
156-
157-
return matcherConfig to filteredOptions
158-
}
159113
}
160114
}

scanner/src/test/kotlin/ScannerMatcherTest.kt

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
package org.ossreviewtoolkit.scanner
2121

2222
import io.kotest.core.spec.style.WordSpec
23-
import io.kotest.matchers.maps.containExactly
24-
import io.kotest.matchers.should
2523
import io.kotest.matchers.shouldBe
2624

2725
import org.ossreviewtoolkit.model.ScannerDetails
@@ -115,36 +113,6 @@ class ScannerMatcherTest : WordSpec({
115113
matcher.matches(testDetails) shouldBe true
116114
}
117115
}
118-
119-
"ScannerMatcherConfig.create()" should {
120-
"obtain values from the options" {
121-
val options = mapOf(
122-
ScannerMatcherConfig.PROP_CRITERIA_NAME to "foo",
123-
ScannerMatcherConfig.PROP_CRITERIA_MIN_VERSION to "1.2.3",
124-
ScannerMatcherConfig.PROP_CRITERIA_MAX_VERSION to "4.5.6",
125-
ScannerMatcherConfig.PROP_CRITERIA_CONFIGURATION to "config"
126-
)
127-
128-
with(ScannerMatcherConfig.create(options).first) {
129-
regScannerName shouldBe "foo"
130-
minVersion shouldBe "1.2.3"
131-
maxVersion shouldBe "4.5.6"
132-
configuration shouldBe "config"
133-
}
134-
}
135-
136-
"filter matcher properties from the options" {
137-
val options = mapOf(
138-
ScannerMatcherConfig.PROP_CRITERIA_NAME to "foo",
139-
ScannerMatcherConfig.PROP_CRITERIA_MIN_VERSION to "1.2.3",
140-
ScannerMatcherConfig.PROP_CRITERIA_MAX_VERSION to "4.5.6",
141-
ScannerMatcherConfig.PROP_CRITERIA_CONFIGURATION to "config",
142-
"other" to "value"
143-
)
144-
145-
ScannerMatcherConfig.create(options).second should containExactly("other" to "value")
146-
}
147-
}
148116
})
149117

150118
private const val SCANNER_NAME = "ScannerMatcherTest"

0 commit comments

Comments
 (0)