Skip to content

Commit

Permalink
refactor(advisors): Align configuration parameters to be called config
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
  • Loading branch information
sschuberth committed Mar 5, 2023
1 parent 29d41b4 commit 56400c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions advisor/src/main/kotlin/advisors/GitHubDefects.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import org.ossreviewtoolkit.utils.ort.showStackTrace
* For these reasons, this advisor is more a reference implementation for ORT's defects model and not necessarily
* suitable for production usage.
*/
class GitHubDefects(name: String, gitHubConfiguration: GitHubDefectsConfiguration) : AdviceProvider(name) {
class GitHubDefects(name: String, config: GitHubDefectsConfiguration) : AdviceProvider(name) {
companion object : Logging {
/**
* The default number of parallel requests executed by this advisor implementation. This value is used if the
Expand All @@ -100,19 +100,19 @@ class GitHubDefects(name: String, gitHubConfiguration: GitHubDefectsConfiguratio
override val details = AdvisorDetails(providerName, enumSetOf(AdvisorCapability.DEFECTS))

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

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

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

/** The service for accessing the GitHub GraphQL API. */
private val service by lazy {
GitHubService.create(
token = gitHubConfiguration.token.orEmpty(),
url = gitHubConfiguration.endpointUrl ?: GitHubService.ENDPOINT,
token = config.token.orEmpty(),
url = config.endpointUrl ?: GitHubService.ENDPOINT,
client = HttpClient(OkHttp)
)
}
Expand Down
12 changes: 6 additions & 6 deletions advisor/src/main/kotlin/advisors/NexusIq.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private val READ_TIMEOUT = Duration.ofSeconds(60)
/**
* A wrapper for [Nexus IQ Server](https://help.sonatype.com/iqserver) security vulnerability data.
*/
class NexusIq(name: String, private val nexusIqConfig: NexusIqConfiguration) : AdviceProvider(name) {
class NexusIq(name: String, private val config: NexusIqConfiguration) : AdviceProvider(name) {
companion object : Logging

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

private val service by lazy {
NexusIqService.create(
nexusIqConfig.serverUrl,
nexusIqConfig.username,
nexusIqConfig.password,
config.serverUrl,
config.username,
config.password,
OkHttpClientHelper.buildClient {
readTimeout(READ_TIMEOUT)
}
Expand Down Expand Up @@ -131,7 +131,7 @@ class NexusIq(name: String, private val nexusIqConfig: NexusIqConfiguration) : A
private fun NexusIqService.SecurityIssue.toVulnerability(): Vulnerability {
val references = mutableListOf<VulnerabilityReference>()

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

references += nexusIqReference
Expand All @@ -149,7 +149,7 @@ class NexusIq(name: String, private val nexusIqConfig: NexusIqConfiguration) : A
components: List<NexusIqService.Component>
): NexusIqService.ComponentDetailsWrapper =
try {
logger.debug { "Querying component details from ${nexusIqConfig.serverUrl}." }
logger.debug { "Querying component details from ${config.serverUrl}." }
service.getComponentDetails(NexusIqService.ComponentsWrapper(components))
} catch (e: HttpException) {
throw IOException(e)
Expand Down
4 changes: 2 additions & 2 deletions advisor/src/main/kotlin/advisors/VulnerableCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private const val BULK_REQUEST_SIZE = 100
* An [AdviceProvider] implementation that obtains security vulnerability information from a
* [VulnerableCode][https://github.com/nexB/vulnerablecode] instance.
*/
class VulnerableCode(name: String, vulnerableCodeConfiguration: VulnerableCodeConfiguration) : AdviceProvider(name) {
class VulnerableCode(name: String, config: VulnerableCodeConfiguration) : AdviceProvider(name) {
class Factory : AbstractAdviceProviderFactory<VulnerableCode>("VulnerableCode") {
override fun create(config: AdvisorConfiguration) = VulnerableCode(type, config.forProvider { vulnerableCode })
}
Expand All @@ -61,7 +61,7 @@ class VulnerableCode(name: String, vulnerableCodeConfiguration: VulnerableCodeCo

private val service by lazy {
VulnerableCodeService.create(
vulnerableCodeConfiguration.serverUrl, vulnerableCodeConfiguration.apiKey, OkHttpClientHelper.buildClient()
config.serverUrl, config.apiKey, OkHttpClientHelper.buildClient()
)
}

Expand Down

0 comments on commit 56400c1

Please sign in to comment.