Skip to content

Commit

Permalink
feat(scancode): Support reading matched_text fields
Browse files Browse the repository at this point in the history
When ScanCode is run with `--license-text`, `matched_text` fields are
added to license findings that contain the matched license text. Support
reading those fields even if they are not used yet. This enables
programmatic use of those fields and / or future use e.g. when
deserializing ScanCode results from ClearlyDefined (which runs ScanCode
with `--license-text`).

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Apr 2, 2024
1 parent b1de439 commit 88d39ff
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ sealed interface LicenseEntry {
val startLine: Int
val endLine: Int
val score: Float
val matchedText: String?

@Serializable
data class Version1(
Expand All @@ -147,7 +148,8 @@ sealed interface LicenseEntry {
val spdxLicenseKey: String? = null, // This might be explicitly set to null in JSON.
override val startLine: Int,
override val endLine: Int,
val matchedRule: LicenseRule
val matchedRule: LicenseRule,
override val matchedText: String? = null
) : LicenseEntry {
override val licenseExpression = matchedRule.licenseExpression
}
Expand All @@ -159,7 +161,8 @@ sealed interface LicenseEntry {
override val endLine: Int,
override val licenseExpression: String,
val spdxLicenseExpression: String? = null, // This might be missing in JSON.
val fromFile: String? = null // This might be missing in JSON.
val fromFile: String? = null, // This might be missing in JSON.
override val matchedText: String? = null
) : LicenseEntry
}

Expand Down

0 comments on commit 88d39ff

Please sign in to comment.