Skip to content

workflow: remove header file, enable detekt #98

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

Merged
merged 5 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ jobs:
- name: "[CLI] Reset"
run: ./build/graal/spp-cli -v admin reset

- run: ./gradlew test -Dtest.profile=integration
- name: Check CLI
run: ./gradlew check -Dtest.profile=integration

- name: Compress CLI
uses: svenstaro/upx-action@v2
Expand Down
16 changes: 0 additions & 16 deletions LICENSE-HEADER.txt

This file was deleted.

44 changes: 43 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ plugins {
id("com.github.johnrengelman.shadow")
id("com.apollographql.apollo3")
id("com.avast.gradle.docker-compose")
id("io.gitlab.arturbosch.detekt")
kotlin("jvm")
}

Expand Down Expand Up @@ -64,6 +65,8 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")

testImplementation("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.21.0")
}

configure<app.cash.licensee.LicenseeExtension> {
Expand Down Expand Up @@ -170,6 +173,45 @@ apollo {
spotless {
kotlin {
targetExclude("**/generated/**")
licenseHeaderFile(file("LICENSE-HEADER.txt"))

val startYear = 2022
val currentYear = Calendar.getInstance().get(Calendar.YEAR)
val copyrightYears = if (startYear == currentYear) {
"$startYear"
} else {
"$startYear-$currentYear"
}

val jetbrainsProject = findProject(":protocol") ?: rootProject
val licenseHeader = Regex("( . Copyright [\\S\\s]+)")
.find(File(jetbrainsProject.projectDir, "LICENSE").readText())!!
.value.lines().joinToString("\n") {
if (it.trim().isEmpty()) {
" *"
} else {
" * " + it.trim()
}
}
val formattedLicenseHeader = buildString {
append("/*\n")
append(
licenseHeader.replace(
"Copyright [yyyy] [name of copyright owner]",
"Source++, the open-source live coding platform.\n" +
" * Copyright (C) $copyrightYears CodeBrig, Inc."
).replace(
"http://www.apache.org/licenses/LICENSE-2.0",
" http://www.apache.org/licenses/LICENSE-2.0"
)
)
append("/")
}
licenseHeader(formattedLicenseHeader)
}
}

detekt {
parallel = true
buildUponDefaultConfig = true
config.setFrom(arrayOf(File(project.rootDir, "detekt.yml")))
}
12 changes: 7 additions & 5 deletions config/detekt/detekt.yml → detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
# https://github.com/detekt/detekt/blob/master/detekt-core/src/main/resources/default-detekt-config.yml

build:
maxIssues: 18 #todo: zero out
maxIssues: 21 #todo: zero out

formatting:
Indentation:
active: true
active: false
CommentSpacing:
active: false
NoWildcardImports:
active: false
ChainWrapping:
active: false
Wrapping:
active: false

style:
MagicNumber:
Expand All @@ -29,11 +33,9 @@ exceptions:
active: false
TooGenericExceptionThrown:
excludes: ['**/test/**']
PrintStackTrace:
excludes: ['**/SourcePlatform.kt', '**/ServiceProvider.kt']

complexity:
LongParameterList:
functionThreshold: 8
LongMethod:
excludes: ['**/test/**']
excludes: ['**/test/**']