Skip to content

Commit

Permalink
Consistently spell it like "metadata"
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Sep 26, 2022
1 parent 077f525 commit 559c536
Show file tree
Hide file tree
Showing 34 changed files with 78 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ analyzer:
url: "https://git-wip-us.apache.org/repos/asf/jena.git"
revision: "jena-3.9.0-rc1"
path: ""
is_meta_data_only: true
is_metadata_only: true
curations: []
- metadata:
id: "Maven:org.apache.jena:jena-arq:3.9.0"
Expand Down Expand Up @@ -2402,7 +2402,7 @@ analyzer:
url: "https://git-wip-us.apache.org/repos/asf/thrift.git"
revision: ""
path: ""
is_meta_data_only: true
is_metadata_only: true
curations: []
- metadata:
id: "Maven:org.apache.xmlbeans:xmlbeans:2.6.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ analyzer:
url: "https://gitbox.apache.org/repos/asf/struts.git"
revision: "STRUTS_2_5_14_1"
path: ""
is_meta_data_only: true
is_metadata_only: true
curations: []
- metadata:
id: "Maven:org.hamcrest:hamcrest-core:1.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ analyzer:
url: "https://gitbox.apache.org/repos/asf/struts.git"
revision: "STRUTS_2_5_14_1"
path: ""
is_meta_data_only: true
is_metadata_only: true
curations: []
- metadata:
id: "Maven:org.hamcrest:hamcrest-core:1.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,4 @@ packages:
url: "https://gitbox.apache.org/repos/asf/struts.git"
revision: "STRUTS_2_5_14_1"
path: ""
is_meta_data_only: true
is_metadata_only: true
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ packages:
url: "https://gitbox.apache.org/repos/asf/struts.git"
revision: "STRUTS_2_5_14_1"
path: ""
is_meta_data_only: true
is_metadata_only: true
- id: "Maven:org.hamcrest:hamcrest-core:1.3"
purl: "pkg:maven/org.hamcrest/[email protected]"
authors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,4 @@ packages:
url: "https://gitbox.apache.org/repos/asf/struts.git"
revision: "STRUTS_2_5_14_1"
path: ""
is_meta_data_only: true
is_metadata_only: true
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ packages:
url: "https://gitbox.apache.org/repos/asf/struts.git"
revision: "STRUTS_2_5_14_1"
path: ""
is_meta_data_only: true
is_metadata_only: true
- id: "Maven:org.hamcrest:hamcrest-core:1.3"
purl: "pkg:maven/org.hamcrest/[email protected]"
authors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ packages:
url: "https://gitbox.apache.org/repos/asf/beam.git"
revision: "v2.3.0-RC3"
path: ""
is_meta_data_only: true
is_metadata_only: true
- id: "Maven:org.apache.commons:commons-lang3:3.5"
purl: "pkg:maven/org.apache.commons/[email protected]"
authors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ packages:
url: "https://gitbox.apache.org/repos/asf/beam.git"
revision: "v2.3.0-RC3"
path: ""
is_meta_data_only: true
is_metadata_only: true
- id: "Maven:org.apache.commons:commons-lang3:3.5"
purl: "pkg:maven/org.apache.commons/[email protected]"
authors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,7 @@ packages:
url: "https://github.com/Kotlin/kotlinx.coroutines.git"
revision: ""
path: ""
is_meta_data_only: true
is_metadata_only: true
curations: []
- metadata:
id: "Maven:org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2"
Expand Down
4 changes: 2 additions & 2 deletions analyzer/src/main/kotlin/managers/Pip.kt
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class Pip(
}.getOrThrow()

// Get the locally available metadata for all installed packages as a fallback.
val installedPackages = getInstalledPackagesWithLocalMetaData(virtualEnvDir, workingDir).associateBy { it.id }
val installedPackages = getInstalledPackagesWithLocalMetadata(virtualEnvDir, workingDir).associateBy { it.id }

val fullDependencyTree = jsonMapper.readTree(jsonFile)
jsonFile.parentFile.safeDeleteRecursively(force = true)
Expand Down Expand Up @@ -649,7 +649,7 @@ class Pip(
}.getOrDefault(Package.EMPTY.copy(id = id))
}

private fun getInstalledPackagesWithLocalMetaData(virtualEnvDir: File, workingDir: File): List<Package> {
private fun getInstalledPackagesWithLocalMetadata(virtualEnvDir: File, workingDir: File): List<Package> {
val allPackages = listAllInstalledPackages(virtualEnvDir, workingDir)

// Invoking 'pip show' once for each package separately is too slow, thus obtain the output for all packages
Expand Down
4 changes: 2 additions & 2 deletions analyzer/src/main/kotlin/managers/utils/MavenSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ class MavenSupport(private val workspaceReader: WorkspaceReader) {
PackageManager.processProjectVcs(it, vcsFromPackage, *vcsFallbackUrls)
} ?: PackageManager.processPackageVcs(vcsFromPackage, *vcsFallbackUrls)

val isSpringMetaDataProject = with(mavenProject) {
val isSpringMetadataProject = with(mavenProject) {
listOf("boot", "cloud").any {
groupId == "org.springframework.$it" && (
artifactId.startsWith("spring-$it-starter") ||
Expand All @@ -734,7 +734,7 @@ class MavenSupport(private val workspaceReader: WorkspaceReader) {
sourceArtifact = sourceRemoteArtifact,
vcs = vcsFromPackage,
vcsProcessed = vcsProcessed,
isMetaDataOnly = mavenProject.packaging == "pom" || isSpringMetaDataProject,
isMetadataOnly = mavenProject.packaging == "pom" || isSpringMetadataProject,
isModified = isBinaryArtifactModified || isSourceArtifactModified
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ internal class NuGetAllPackageData(

// See https://docs.microsoft.com/en-us/nuget/reference/nuspec.
data class PackageSpec(
val metadata: MetaData
val metadata: Metadata
)

@JsonIgnoreProperties(ignoreUnknown = true)
data class MetaData(
data class Metadata(
// See https://docs.microsoft.com/en-us/nuget/reference/nuspec#required-metadata-elements
val id: String,
val version: String,
Expand Down
2 changes: 1 addition & 1 deletion downloader/src/main/kotlin/Downloader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Downloader(private val config: DownloaderConfiguration) {
fun download(pkg: Package, outputDirectory: File): Provenance {
verifyOutputDirectory(outputDirectory)

if (pkg.isMetaDataOnly) return UnknownProvenance
if (pkg.isMetadataOnly) return UnknownProvenance

val exception = DownloadException("Download failed for '${pkg.id.toCoordinates()}'.")

Expand Down
6 changes: 3 additions & 3 deletions evaluator/src/main/kotlin/PackageRule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ open class PackageRule(
/**
* A [RuleMatcher] that checks whether the [package][pkg] is metadata only.
*/
fun isMetaDataOnly() =
fun isMetadataOnly() =
object : RuleMatcher {
override val description = "isMetaDataOnly()"
override val description = "isMetadataOnly()"

override fun matches() = pkg.metadata.isMetaDataOnly
override fun matches() = pkg.metadata.isMetadataOnly
}

/**
Expand Down
8 changes: 4 additions & 4 deletions evaluator/src/test/kotlin/PackageRuleTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,17 @@ class PackageRuleTest : WordSpec() {
}
}

"isMetaDataOnly()" should {
"isMetadataOnly()" should {
"return true for a package that has only metadata" {
val rule = createPackageRule(packageMetaDataOnly)
val matcher = rule.isMetaDataOnly()
val rule = createPackageRule(packageMetadataOnly)
val matcher = rule.isMetadataOnly()

matcher.matches() shouldBe true
}

"return false for a package that has not only metadata" {
val rule = createPackageRule(packageWithoutLicense)
val matcher = rule.isMetaDataOnly()
val matcher = rule.isMetadataOnly()

matcher.matches() shouldBe false
}
Expand Down
8 changes: 4 additions & 4 deletions evaluator/src/test/kotlin/TestData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ val packageWithVulnerabilities = Package.EMPTY.copy(
id = Identifier("Maven:org.ossreviewtoolkit:package-with-vulnerabilities:1.0")
)

val packageMetaDataOnly = Package.EMPTY.copy(
val packageMetadataOnly = Package.EMPTY.copy(
id = Identifier("Maven:org.ossreviewtoolkit:package-metadata-only:1.0"),
isMetaDataOnly = true
isMetadataOnly = true
)

val packageDependency = Package.EMPTY.copy(
Expand All @@ -135,7 +135,7 @@ val allPackages = listOf(
packageWithOnlyConcludedLicense,
packageWithOnlyDeclaredLicense,
packageWithConcludedAndDeclaredLicense,
packageMetaDataOnly,
packageMetadataOnly,
packageDependency
)

Expand Down Expand Up @@ -165,7 +165,7 @@ val scopeIncluded = Scope(
packageWithConcludedAndDeclaredLicense.toReference(),
packageRefDynamicallyLinked,
packageRefStaticallyLinked,
packageMetaDataOnly.toReference()
packageMetadataOnly.toReference()
)
)

Expand Down
6 changes: 4 additions & 2 deletions model/src/main/kotlin/Package.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.ossreviewtoolkit.model

import com.fasterxml.jackson.annotation.JsonAlias
import com.fasterxml.jackson.annotation.JsonInclude

import java.util.SortedSet
Expand Down Expand Up @@ -119,8 +120,9 @@ data class Package(
* Indicates whether the package is just metadata, like e.g. Maven BOM artifacts which only define constraints
* for dependency versions.
*/
@JsonAlias("is_meta_data_only")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
val isMetaDataOnly: Boolean = false,
val isMetadataOnly: Boolean = false,

/**
* Indicates whether the source code of the package has been modified compared to the original source code,
Expand Down Expand Up @@ -172,7 +174,7 @@ data class Package(
binaryArtifact = binaryArtifact.takeIf { it != other.binaryArtifact },
sourceArtifact = sourceArtifact.takeIf { it != other.sourceArtifact },
vcs = vcsProcessed.takeIf { it != other.vcsProcessed }?.toCuration(),
isMetaDataOnly = isMetaDataOnly.takeIf { it != other.isMetaDataOnly },
isMetadataOnly = isMetadataOnly.takeIf { it != other.isMetadataOnly },
isModified = isModified.takeIf { it != other.isModified }
)
}
Expand Down
8 changes: 5 additions & 3 deletions model/src/main/kotlin/PackageCurationData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.ossreviewtoolkit.model

import com.fasterxml.jackson.annotation.JsonAlias
import com.fasterxml.jackson.annotation.JsonInclude

import java.util.SortedSet
Expand Down Expand Up @@ -89,7 +90,8 @@ data class PackageCurationData(
/**
* Whether the package is metadata only.
*/
val isMetaDataOnly: Boolean? = null,
@JsonAlias("is_meta_data_only")
val isMetadataOnly: Boolean? = null,

/**
* Whether the package is modified compared to the original source
Expand Down Expand Up @@ -140,7 +142,7 @@ data class PackageCurationData(
sourceArtifact = sourceArtifact ?: original.sourceArtifact,
vcs = original.vcs,
vcsProcessed = vcsProcessed,
isMetaDataOnly = isMetaDataOnly ?: original.isMetaDataOnly,
isMetadataOnly = isMetadataOnly ?: original.isMetadataOnly,
isModified = isModified ?: original.isModified
)

Expand Down Expand Up @@ -176,7 +178,7 @@ data class PackageCurationData(
binaryArtifact = binaryArtifact ?: other.binaryArtifact,
sourceArtifact = sourceArtifact ?: other.sourceArtifact,
vcs = vcs?.merge(other.vcs ?: vcs) ?: other.vcs,
isMetaDataOnly = isMetaDataOnly ?: other.isMetaDataOnly,
isMetadataOnly = isMetadataOnly ?: other.isMetadataOnly,
isModified = isModified ?: other.isModified,
declaredLicenseMapping = declaredLicenseMapping.zip(other.declaredLicenseMapping) { value, otherValue ->
(value ?: otherValue)!!
Expand Down
8 changes: 4 additions & 4 deletions model/src/test/kotlin/PackageCurationDataTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PackageCurationDataTest : WordSpec({
revision = "original",
path = "original"
),
isMetaDataOnly = true,
isMetadataOnly = true,
isModified = true,
declaredLicenseMapping = mapOf("original" to "original".toSpdx())
)
Expand All @@ -74,7 +74,7 @@ class PackageCurationDataTest : WordSpec({
revision = "other",
path = "other"
),
isMetaDataOnly = false,
isMetadataOnly = false,
isModified = false,
declaredLicenseMapping = mapOf("other" to "other".toSpdx())
)
Expand All @@ -91,7 +91,7 @@ class PackageCurationDataTest : WordSpec({
concludedLicense = null,
binaryArtifact = null,
vcs = null,
isMetaDataOnly = null,
isMetadataOnly = null,
declaredLicenseMapping = emptyMap()
)

Expand All @@ -101,7 +101,7 @@ class PackageCurationDataTest : WordSpec({
concludedLicense = other.concludedLicense,
binaryArtifact = other.binaryArtifact,
vcs = other.vcs,
isMetaDataOnly = other.isMetaDataOnly,
isMetadataOnly = other.isMetadataOnly,
declaredLicenseMapping = other.declaredLicenseMapping
)
}
Expand Down
18 changes: 9 additions & 9 deletions model/src/test/kotlin/PackageCurationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PackageCurationTest : WordSpec({
binaryArtifact = RemoteArtifact.EMPTY,
sourceArtifact = RemoteArtifact.EMPTY,
vcs = VcsInfo.EMPTY,
isMetaDataOnly = false,
isMetadataOnly = false,
isModified = false
)

Expand Down Expand Up @@ -74,7 +74,7 @@ class PackageCurationTest : WordSpec({
revision = "revision",
path = "path"
),
isMetaDataOnly = true,
isMetadataOnly = true,
isModified = true
)
)
Expand All @@ -96,7 +96,7 @@ class PackageCurationTest : WordSpec({
sourceArtifact shouldBe curation.data.sourceArtifact
vcs shouldBe pkg.vcs
vcsProcessed.toCuration() shouldBe curation.data.vcs
isMetaDataOnly shouldBe true
isMetadataOnly shouldBe true
isModified shouldBe true
}

Expand Down Expand Up @@ -126,7 +126,7 @@ class PackageCurationTest : WordSpec({
revision = "revision",
path = "path"
),
isMetaDataOnly = false,
isMetadataOnly = false,
isModified = false
)

Expand Down Expand Up @@ -159,7 +159,7 @@ class PackageCurationTest : WordSpec({
revision = pkg.vcs.revision,
path = pkg.vcs.path
)
isMetaDataOnly shouldBe false
isMetadataOnly shouldBe false
isModified shouldBe false
}

Expand Down Expand Up @@ -242,7 +242,7 @@ class PackageCurationTest : WordSpec({
}
}

"be able to clear isMetaDataOnly" {
"be able to clear isMetadataOnly" {
val pkg = Package(
id = Identifier(
type = "Maven",
Expand All @@ -257,19 +257,19 @@ class PackageCurationTest : WordSpec({
binaryArtifact = RemoteArtifact.EMPTY,
sourceArtifact = RemoteArtifact.EMPTY,
vcs = VcsInfo.EMPTY,
isMetaDataOnly = true
isMetadataOnly = true
)

val curation = PackageCuration(
id = pkg.id,
data = PackageCurationData(
isMetaDataOnly = false
isMetadataOnly = false
)
)

val curatedPkg = curation.apply(pkg.toCuratedPackage())

curatedPkg.metadata.isMetaDataOnly shouldBe false
curatedPkg.metadata.isMetadataOnly shouldBe false
}

"be able to clear isModified" {
Expand Down
Loading

0 comments on commit 559c536

Please sign in to comment.