Skip to content

Commit 56400c1

Browse files
committed
refactor(advisors): Align configuration parameters to be called config
Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 29d41b4 commit 56400c1

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

advisor/src/main/kotlin/advisors/GitHubDefects.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ import org.ossreviewtoolkit.utils.ort.showStackTrace
8080
* For these reasons, this advisor is more a reference implementation for ORT's defects model and not necessarily
8181
* suitable for production usage.
8282
*/
83-
class GitHubDefects(name: String, gitHubConfiguration: GitHubDefectsConfiguration) : AdviceProvider(name) {
83+
class GitHubDefects(name: String, config: GitHubDefectsConfiguration) : AdviceProvider(name) {
8484
companion object : Logging {
8585
/**
8686
* The default number of parallel requests executed by this advisor implementation. This value is used if the
@@ -100,19 +100,19 @@ class GitHubDefects(name: String, gitHubConfiguration: GitHubDefectsConfiguratio
100100
override val details = AdvisorDetails(providerName, enumSetOf(AdvisorCapability.DEFECTS))
101101

102102
/** The filters to be applied to issue labels. */
103-
private val labelFilters = gitHubConfiguration.labelFilter.toLabelFilters()
103+
private val labelFilters = config.labelFilter.toLabelFilters()
104104

105105
/** The maximum number of defects to retrieve. */
106-
private val maxDefects = gitHubConfiguration.maxNumberOfIssuesPerRepository ?: Int.MAX_VALUE
106+
private val maxDefects = config.maxNumberOfIssuesPerRepository ?: Int.MAX_VALUE
107107

108108
/** The number of requests to be processed in parallel. */
109-
private val parallelRequests = gitHubConfiguration.parallelRequests ?: DEFAULT_PARALLEL_REQUESTS
109+
private val parallelRequests = config.parallelRequests ?: DEFAULT_PARALLEL_REQUESTS
110110

111111
/** The service for accessing the GitHub GraphQL API. */
112112
private val service by lazy {
113113
GitHubService.create(
114-
token = gitHubConfiguration.token.orEmpty(),
115-
url = gitHubConfiguration.endpointUrl ?: GitHubService.ENDPOINT,
114+
token = config.token.orEmpty(),
115+
url = config.endpointUrl ?: GitHubService.ENDPOINT,
116116
client = HttpClient(OkHttp)
117117
)
118118
}

advisor/src/main/kotlin/advisors/NexusIq.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private val READ_TIMEOUT = Duration.ofSeconds(60)
6060
/**
6161
* A wrapper for [Nexus IQ Server](https://help.sonatype.com/iqserver) security vulnerability data.
6262
*/
63-
class NexusIq(name: String, private val nexusIqConfig: NexusIqConfiguration) : AdviceProvider(name) {
63+
class NexusIq(name: String, private val config: NexusIqConfiguration) : AdviceProvider(name) {
6464
companion object : Logging
6565

6666
class Factory : AbstractAdviceProviderFactory<NexusIq>("NexusIQ") {
@@ -71,9 +71,9 @@ class NexusIq(name: String, private val nexusIqConfig: NexusIqConfiguration) : A
7171

7272
private val service by lazy {
7373
NexusIqService.create(
74-
nexusIqConfig.serverUrl,
75-
nexusIqConfig.username,
76-
nexusIqConfig.password,
74+
config.serverUrl,
75+
config.username,
76+
config.password,
7777
OkHttpClientHelper.buildClient {
7878
readTimeout(READ_TIMEOUT)
7979
}
@@ -131,7 +131,7 @@ class NexusIq(name: String, private val nexusIqConfig: NexusIqConfiguration) : A
131131
private fun NexusIqService.SecurityIssue.toVulnerability(): Vulnerability {
132132
val references = mutableListOf<VulnerabilityReference>()
133133

134-
val browseUrl = URI("${nexusIqConfig.browseUrl}/assets/index.html#/vulnerabilities/$reference")
134+
val browseUrl = URI("${config.browseUrl}/assets/index.html#/vulnerabilities/$reference")
135135
val nexusIqReference = VulnerabilityReference(browseUrl, scoringSystem(), severity.toString())
136136

137137
references += nexusIqReference
@@ -149,7 +149,7 @@ class NexusIq(name: String, private val nexusIqConfig: NexusIqConfiguration) : A
149149
components: List<NexusIqService.Component>
150150
): NexusIqService.ComponentDetailsWrapper =
151151
try {
152-
logger.debug { "Querying component details from ${nexusIqConfig.serverUrl}." }
152+
logger.debug { "Querying component details from ${config.serverUrl}." }
153153
service.getComponentDetails(NexusIqService.ComponentsWrapper(components))
154154
} catch (e: HttpException) {
155155
throw IOException(e)

advisor/src/main/kotlin/advisors/VulnerableCode.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private const val BULK_REQUEST_SIZE = 100
4848
* An [AdviceProvider] implementation that obtains security vulnerability information from a
4949
* [VulnerableCode][https://github.com/nexB/vulnerablecode] instance.
5050
*/
51-
class VulnerableCode(name: String, vulnerableCodeConfiguration: VulnerableCodeConfiguration) : AdviceProvider(name) {
51+
class VulnerableCode(name: String, config: VulnerableCodeConfiguration) : AdviceProvider(name) {
5252
class Factory : AbstractAdviceProviderFactory<VulnerableCode>("VulnerableCode") {
5353
override fun create(config: AdvisorConfiguration) = VulnerableCode(type, config.forProvider { vulnerableCode })
5454
}
@@ -61,7 +61,7 @@ class VulnerableCode(name: String, vulnerableCodeConfiguration: VulnerableCodeCo
6161

6262
private val service by lazy {
6363
VulnerableCodeService.create(
64-
vulnerableCodeConfiguration.serverUrl, vulnerableCodeConfiguration.apiKey, OkHttpClientHelper.buildClient()
64+
config.serverUrl, config.apiKey, OkHttpClientHelper.buildClient()
6565
)
6666
}
6767

0 commit comments

Comments
 (0)