Skip to content

Commit b6bd37a

Browse files
authored
workflow: remove header file, enable detekt (#98)
* refactor: remove license header file fixes sourceplusplus/sourceplusplus#559 * workflow: re-enable detekt * workflow: check cli * Update detekt.yml
1 parent c9bb925 commit b6bd37a

File tree

4 files changed

+52
-23
lines changed

4 files changed

+52
-23
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ jobs:
226226
- name: "[CLI] Reset"
227227
run: ./build/graal/spp-cli -v admin reset
228228

229-
- run: ./gradlew test -Dtest.profile=integration
229+
- name: Check CLI
230+
run: ./gradlew check -Dtest.profile=integration
230231

231232
- name: Compress CLI
232233
uses: svenstaro/upx-action@v2

LICENSE-HEADER.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

build.gradle.kts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ plugins {
1717
id("com.github.johnrengelman.shadow")
1818
id("com.apollographql.apollo3")
1919
id("com.avast.gradle.docker-compose")
20+
id("io.gitlab.arturbosch.detekt")
2021
kotlin("jvm")
2122
}
2223

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

6667
testImplementation("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
68+
69+
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.21.0")
6770
}
6871

6972
configure<app.cash.licensee.LicenseeExtension> {
@@ -170,6 +173,45 @@ apollo {
170173
spotless {
171174
kotlin {
172175
targetExclude("**/generated/**")
173-
licenseHeaderFile(file("LICENSE-HEADER.txt"))
176+
177+
val startYear = 2022
178+
val currentYear = Calendar.getInstance().get(Calendar.YEAR)
179+
val copyrightYears = if (startYear == currentYear) {
180+
"$startYear"
181+
} else {
182+
"$startYear-$currentYear"
183+
}
184+
185+
val jetbrainsProject = findProject(":protocol") ?: rootProject
186+
val licenseHeader = Regex("( . Copyright [\\S\\s]+)")
187+
.find(File(jetbrainsProject.projectDir, "LICENSE").readText())!!
188+
.value.lines().joinToString("\n") {
189+
if (it.trim().isEmpty()) {
190+
" *"
191+
} else {
192+
" * " + it.trim()
193+
}
194+
}
195+
val formattedLicenseHeader = buildString {
196+
append("/*\n")
197+
append(
198+
licenseHeader.replace(
199+
"Copyright [yyyy] [name of copyright owner]",
200+
"Source++, the open-source live coding platform.\n" +
201+
" * Copyright (C) $copyrightYears CodeBrig, Inc."
202+
).replace(
203+
"http://www.apache.org/licenses/LICENSE-2.0",
204+
" http://www.apache.org/licenses/LICENSE-2.0"
205+
)
206+
)
207+
append("/")
208+
}
209+
licenseHeader(formattedLicenseHeader)
174210
}
175211
}
212+
213+
detekt {
214+
parallel = true
215+
buildUponDefaultConfig = true
216+
config.setFrom(arrayOf(File(project.rootDir, "detekt.yml")))
217+
}

config/detekt/detekt.yml renamed to detekt.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
# https://github.com/detekt/detekt/blob/master/detekt-core/src/main/resources/default-detekt-config.yml
33

44
build:
5-
maxIssues: 18 #todo: zero out
5+
maxIssues: 21 #todo: zero out
66

77
formatting:
88
Indentation:
9-
active: true
9+
active: false
1010
CommentSpacing:
1111
active: false
1212
NoWildcardImports:
1313
active: false
14+
ChainWrapping:
15+
active: false
16+
Wrapping:
17+
active: false
1418

1519
style:
1620
MagicNumber:
@@ -29,11 +33,9 @@ exceptions:
2933
active: false
3034
TooGenericExceptionThrown:
3135
excludes: ['**/test/**']
32-
PrintStackTrace:
33-
excludes: ['**/SourcePlatform.kt', '**/ServiceProvider.kt']
3436

3537
complexity:
3638
LongParameterList:
3739
functionThreshold: 8
3840
LongMethod:
39-
excludes: ['**/test/**']
41+
excludes: ['**/test/**']

0 commit comments

Comments
 (0)