Skip to content

Commit

Permalink
refactor(black-duck): Move two variables out of a block
Browse files Browse the repository at this point in the history
Avoid recomuting the values and reduce the nesting level.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Jan 29, 2025
1 parent 668b36a commit d44e232
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions plugins/advisors/black-duck/src/main/kotlin/BlackDuck.kt
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,11 @@ class BlackDuck(

internal fun VulnerabilityView.toOrtVulnerability(): Vulnerability {
val referenceUris = setOf(meta.href.uri(), *meta.links.map { it.href.uri() }.toTypedArray())
val cvssVector = cvss3?.vector ?: cvss2?.vector
// Only CVSS version 2 vectors do not contain the "CVSS:" label and version prefix
val scoringSystem = cvssVector?.substringBefore('/', Cvss2Rating.PREFIXES.first())

val references = referenceUris.map { uri ->
val cvssVector = cvss3?.vector ?: cvss2?.vector
// Only CVSS version 2 vectors do not contain the "CVSS:" label and version prefix
val scoringSystem = cvssVector?.substringBefore('/', Cvss2Rating.PREFIXES.first())

VulnerabilityReference(
url = uri,
scoringSystem = scoringSystem,
Expand Down

0 comments on commit d44e232

Please sign in to comment.