Skip to content

Commit ec7a4d7

Browse files
Merge branch 'oss-review-toolkit:main' into feat/scanoss/exclusion-patterns-and-snippet-choices
2 parents bfd7a6d + e855ea5 commit ec7a4d7

File tree

62 files changed

+921
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+921
-383
lines changed

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
with:
109109
fetch-depth: 0
110110
- name: Qodana Scan
111-
uses: JetBrains/qodana-action@491da5246a31d74fe3fe86db365d16e4d4edfb91 # v2025.1.0
111+
uses: JetBrains/qodana-action@e14351bdf4707c4cecc25a86a9190745b7b40de8 # v2025.1.1
112112
with:
113113
post-pr-comment: false
114114
use-caches: false

downloader/src/main/kotlin/WorkingTreeCache.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import kotlinx.coroutines.sync.withLock
2727
import org.apache.logging.log4j.kotlin.logger
2828

2929
import org.ossreviewtoolkit.model.VcsInfo
30+
import org.ossreviewtoolkit.plugins.api.PluginConfig
3031
import org.ossreviewtoolkit.utils.common.safeDeleteRecursively
3132
import org.ossreviewtoolkit.utils.ort.createOrtTempDir
3233

@@ -55,11 +56,23 @@ interface WorkingTreeCache {
5556

5657
class DefaultWorkingTreeCache : WorkingTreeCache {
5758
private val mutex = Mutex()
59+
private val vcsPluginConfigs = mutableMapOf<String, PluginConfig>()
5860
private val workingTreeMutexes = mutableMapOf<String, Mutex>()
5961
private val workingTrees = mutableMapOf<String, WorkingTree>()
6062

6163
private var terminated = false
6264

65+
/**
66+
* Add [VCS plugin configurations][configs] that are applied when creating a [VersionControlSystem] instance
67+
* for this working tree. Calling this function is optional.
68+
*/
69+
@Suppress("unused") // Intended for use when this class is consumed externally as a library.
70+
fun addVcsPluginConfigs(configs: Map<String, PluginConfig>): DefaultWorkingTreeCache {
71+
logger.debug { "Using VCS plugin configs: $configs" }
72+
vcsPluginConfigs += configs
73+
return this
74+
}
75+
6376
override suspend fun <T> use(vcsInfo: VcsInfo, block: (VersionControlSystem, WorkingTree) -> T): T {
6477
val vcs = getVcs(vcsInfo)
6578
return getWorkingTreeMutex(vcsInfo).withLock { block(vcs, getWorkingTree(vcsInfo, vcs)) }
@@ -75,8 +88,8 @@ class DefaultWorkingTreeCache : WorkingTreeCache {
7588
}
7689

7790
private fun getVcs(vcsInfo: VcsInfo) =
78-
VersionControlSystem.forType(vcsInfo.type)
79-
?: VersionControlSystem.forUrl(vcsInfo.url)
91+
VersionControlSystem.forType(vcsInfo.type, vcsPluginConfigs)
92+
?: VersionControlSystem.forUrl(vcsInfo.url, vcsPluginConfigs)
8093
?: throw IOException("Could not determine VCS for type '${vcsInfo.type}' and URL ${vcsInfo.url}.")
8194

8295
private fun getWorkingTree(vcsInfo: VcsInfo, vcs: VersionControlSystem) =

evaluator/src/main/kotlin/PackageRule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ open class PackageRule(
5757
) : Rule(ruleSet, name) {
5858
private val licenseRules = mutableListOf<LicenseRule>()
5959

60-
@Suppress("UNUSED") // This is intended to be used by rule implementations.
60+
@Suppress("unused") // This is intended to be used by rule implementations.
6161
val uncuratedPkg: Package by lazy {
6262
@Suppress("UnsafeCallOnNullableType")
6363
ruleSet.ortResult.getUncuratedPackageOrProject(pkg.metadata.id)!!

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
buildConfigPlugin = "5.6.4"
2+
buildConfigPlugin = "5.6.5"
33
dependencyAnalysisPlugin = "2.17.0"
44
detektPlugin = "1.23.8"
55
dokkatooPlugin = "2.4.0"

model/src/main/kotlin/OrtResult.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ data class OrtResult(
214214
/**
215215
* Return the list of [AdvisorResult]s for the given [id].
216216
*/
217-
@Suppress("UNUSED")
217+
@Suppress("unused")
218218
fun getAdvisorResultsForId(id: Identifier): List<AdvisorResult> = advisorResultsById[id].orEmpty()
219219

220220
/**
@@ -375,7 +375,7 @@ data class OrtResult(
375375
* [omitExcluded] is set to true, excluded projects / packages are omitted from the result. Projects are converted
376376
* to packages in the result. If no analyzer result is present an empty set is returned.
377377
*/
378-
@Suppress("UNUSED") // This is intended to be mostly used via scripting.
378+
@Suppress("unused") // This is intended to be mostly used via scripting.
379379
fun getOrgPackages(vararg names: String, omitExcluded: Boolean = false): Set<Package> {
380380
val vendorPackages = mutableSetOf<Package>()
381381

model/src/main/kotlin/TextLocation.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.ossreviewtoolkit.model
2121

22+
import com.fasterxml.jackson.annotation.JsonIgnore
23+
2224
import java.io.File
2325

2426
import kotlin.math.abs
@@ -65,6 +67,16 @@ data class TextLocation(
6567
*/
6668
constructor(path: String, line: Int) : this(path, line, line)
6769

70+
/**
71+
* Indicate whether this TextLocation has known start and end lines.
72+
*/
73+
@JsonIgnore
74+
val hasLineRange = startLine != UNKNOWN_LINE && endLine != UNKNOWN_LINE
75+
76+
/**
77+
* Return a negative integer, zero, or a positive integer as this TextLocation comes before, is the same, or comes
78+
* after the [other] TextLocation.
79+
*/
6880
override fun compareTo(other: TextLocation) = COMPARATOR.compare(this, other)
6981

7082
/**

notifier/src/main/kotlin/modules/JiraNotifier.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class JiraNotifier(private val restClient: JiraRestClient) {
4343
/**
4444
* Create a [comment] within the issue specified by the [issueKey].
4545
*/
46-
@Suppress("UNUSED") // This is intended to be used via scripting.
46+
@Suppress("unused") // This is intended to be used via scripting.
4747
fun createComment(issueKey: String, comment: String) {
4848
val issue = restClient.issueClient.getIssue(issueKey).claim()
4949

notifier/src/main/kotlin/modules/MailNotifier.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class MailNotifier(private val config: SendMailConfiguration) {
5858
* is set to false, a single-part plain-text email is sent. Otherwise, a multi-part HTML email with an additional
5959
* plain-text part as a fallback is sent. Throws a [MessagingException] if the email could not be sent.
6060
*/
61-
@Suppress("UNUSED") // This is intended to be used by notification script implementations.
61+
@Suppress("unused") // This is intended to be used by notification script implementations.
6262
fun sendMail(
6363
subject: String,
6464
message: String,

plugins/api/src/main/kotlin/OrtPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import kotlin.reflect.KClass
3333
annotation class OrtPlugin(
3434
/**
3535
* The id of the plugin. Must be unique among all plugins for the same extension point. If empty, the id is derived
36-
* from the class name by removing the plugin's parent class name as a suffix.
36+
* from the class name by removing the plugin's parent class name (with any "Ort" prefix stripped) as a suffix.
3737
*/
3838
val id: String = "",
3939

plugins/commands/advisor/src/main/kotlin/AdvisorCommand.kt renamed to plugins/commands/advisor/src/main/kotlin/AdviseCommand.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,11 @@ import org.ossreviewtoolkit.utils.ort.ORT_RESOLUTIONS_FILENAME
6161
import org.ossreviewtoolkit.utils.ort.ortConfigDirectory
6262

6363
@OrtPlugin(
64-
id = "advise",
6564
displayName = "advise command",
6665
description = "Check dependencies for security vulnerabilities.",
6766
factory = OrtCommandFactory::class
6867
)
69-
class AdvisorCommand(descriptor: PluginDescriptor = AdvisorCommandFactory.descriptor) : OrtCommand(descriptor) {
68+
class AdviseCommand(descriptor: PluginDescriptor = AdviseCommandFactory.descriptor) : OrtCommand(descriptor) {
7069
private val ortFile by option(
7170
"--ort-file", "-i",
7271
help = "An ORT result file with an analyzer result to use."

0 commit comments

Comments
 (0)