diff --git a/build.gradle.kts b/build.gradle.kts index 332d6deab74a2..f3345a9692154 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -152,7 +152,7 @@ val checkLicenseHeaders by tasks.registering { val headerLines = LicenseUtils.extractHeader(file) val holders = CopyrightUtils.extractHolders(headerLines) - if (holders.singleOrNull() != CopyrightUtils.expectedHolder) { + if (holders.singleOrNull() != CopyrightUtils.EXPECTED_HOLDER) { hasErrors = true logger.error("Unexpected copyright holder(s) in file '$file': $holders") } diff --git a/buildSrc/src/main/kotlin/LicenseUtils.kt b/buildSrc/src/main/kotlin/LicenseUtils.kt index 7632faa67d3e6..3584c13a459fc 100644 --- a/buildSrc/src/main/kotlin/LicenseUtils.kt +++ b/buildSrc/src/main/kotlin/LicenseUtils.kt @@ -71,10 +71,10 @@ object CopyrightableFiles { } object CopyrightUtils { - const val expectedHolder = + const val EXPECTED_HOLDER = "The ORT Project Authors (see )" - private const val maxCopyrightLines = 50 + private const val MAX_COPYRIGHT_LINES = 50 private val copyrightPrefixRegex = Regex("Copyright .*\\d{2,}(-\\d{2,})? ", RegexOption.IGNORE_CASE) fun extract(file: File): List { @@ -84,7 +84,7 @@ object CopyrightUtils { file.useLines { lines -> lines.forEach { line -> - if (++lineCounter > maxCopyrightLines) return@forEach + if (++lineCounter > MAX_COPYRIGHT_LINES) return@forEach val copyright = line.replaceBefore(" Copyright ", "", "").trim() if (copyright.isNotEmpty() && !copyright.endsWith("\"")) copyrights += copyright } @@ -123,11 +123,11 @@ object LicenseUtils { SPDX-License-Identifier: Apache-2.0 """.trimIndent() - private const val lastHeaderLine = "License-Filename: LICENSE" + private const val LAST_HEADER_LINE = "License-Filename: LICENSE" fun extractHeader(file: File): List { var headerLines = file.useLines { lines -> - lines.takeWhile { !it.endsWith(lastHeaderLine) }.toList() + lines.takeWhile { !it.endsWith(LAST_HEADER_LINE) }.toList() } while (true) {