Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detection of files without curation #9487

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion model/src/main/kotlin/licenses/DefaultLicenseInfoProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import java.util.concurrent.ConcurrentMap

import org.ossreviewtoolkit.model.Identifier
import org.ossreviewtoolkit.model.LicenseFinding
import org.ossreviewtoolkit.model.OrtResult
import org.ossreviewtoolkit.model.Provenance
import org.ossreviewtoolkit.model.TextLocation
import org.ossreviewtoolkit.model.config.LicenseFindingCuration
import org.ossreviewtoolkit.model.config.PathExclude
import org.ossreviewtoolkit.model.utils.filterByVcsPath
Expand Down Expand Up @@ -79,6 +81,7 @@
private fun createDetectedLicenseInfo(id: Identifier): DetectedLicenseInfo {
val findings = mutableListOf<Findings>()

val files = ortResult.getFileListForId(id)
ortResult.getScanResultsForId(id).map {
// If a VCS path curation has been applied after the scanning stage, it is possible to apply that
// curation without re-scanning in case the new VCS path is a subdirectory of the scanned VCS path.
Expand All @@ -87,10 +90,18 @@
it.filterByVcsPath(ortResult.getPackage(id)?.metadata?.vcsProcessed?.path.orEmpty())
}.forEach { (provenance, _, summary, _) ->
val config = getConfiguration(id, provenance)
val licenseFiles = summary.licenseFindings.map { it.location.path }

val unlicensedFiles = files?.files.orEmpty().asSequence().filterNot { it.path in licenseFiles }.map {
LicenseFinding(
license = "NONE",
location = TextLocation(it.path, 1)
)

Check warning on line 99 in model/src/main/kotlin/licenses/DefaultLicenseInfoProvider.kt

View check run for this annotation

Codecov / codecov/patch

model/src/main/kotlin/licenses/DefaultLicenseInfoProvider.kt#L96-L99

Added lines #L96 - L99 were not covered by tests
}.toSet()

findings += Findings(
provenance = provenance,
licenses = summary.licenseFindings,
licenses = summary.licenseFindings union unlicensedFiles,
copyrights = summary.copyrightFindings,
licenseFindingCurations = config.licenseFindingCurations,
pathExcludes = config.pathExcludes,
Expand Down
Loading