Skip to content

Commit

Permalink
style(Gradle): Adhere to const naming conventions
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Apr 4, 2024
1 parent e407d11 commit 1a10da7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/LicenseUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ object CopyrightableFiles {
}

object CopyrightUtils {
const val expectedHolder =
const val EXPECTED_HOLDER =
"The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)"

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<String> {
Expand All @@ -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
}
Expand Down Expand Up @@ -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<String> {
var headerLines = file.useLines { lines ->
lines.takeWhile { !it.endsWith(lastHeaderLine) }.toList()
lines.takeWhile { !it.endsWith(LAST_HEADER_LINE) }.toList()
}

while (true) {
Expand Down

0 comments on commit 1a10da7

Please sign in to comment.