Skip to content

Commit 4d84e9e

Browse files
authored
Add Kotlin support (Draegerwerk#153)
Added kotlin, detekt and konsist. # Checklist The following aspects have been respected by the author of this pull request, confirmed by both pull request assignee **and** reviewer: * Adherence to coding conventions * [x] Pull Request Assignee * [x] Reviewer * Adherence to javadoc conventions * [x] Pull Request Assignee * [x] Reviewer * Changelog update (necessity checked and entry added or not added respectively) * [x] Pull Request Assignee * [x] Reviewer * README update (necessity checked and entry added or not added respectively) * [x] Pull Request Assignee * [x] Reviewer * config update (necessity checked and entry added or not added respectively) * [x] Pull Request Assignee * [x] Reviewer * SDCcc executable ran against a test device (if necessary) * [x] Pull Request Assignee * [x] Reviewer
1 parent d6242d3 commit 4d84e9e

File tree

7 files changed

+177
-3
lines changed

7 files changed

+177
-3
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
if: startsWith(github.ref, 'refs/tags/')
9393
working-directory: sdccc/target/
9494
run: |
95-
zip -qq -r test-results.zip failsafe-reports surefire-reports checkstyle-result.xml spotbugsXml.xml
95+
zip -qq -r test-results.zip failsafe-reports surefire-reports checkstyle-result.xml spotbugsXml.xml detekt.html
9696
9797
- name: Attach artifacts to snapshot
9898
uses: softprops/action-gh-release@v1

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- support for Kotlin
12+
913
### Changed
1014

1115
- sdc-ri version to 6.0.0-SNAPSHOT

dev_config/detekt.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
comments:
2+
DeprecatedBlockTag:
3+
active: true
4+
EndOfSentenceFormat:
5+
active: true
6+
KDocReferencesNonPublicProperty:
7+
active: true
8+
OutdatedDocumentation:
9+
active: true
10+
complexity:
11+
NamedArguments:
12+
active: true
13+
ReplaceSafeCallChainWithRun:
14+
active: true
15+
exceptions:
16+
ObjectExtendsThrowable:
17+
active: true
18+
ThrowingExceptionInMain:
19+
active: true
20+
performance:
21+
CouldBeSequence:
22+
active: true
23+
potential-bugs:
24+
CastToNullableType:
25+
active: true
26+
DontDowncastCollectionTypes:
27+
active: true
28+
ElseCaseInsteadOfExhaustiveWhen:
29+
active: true
30+
ExitOutsideMain:
31+
active: true
32+
MissingPackageDeclaration:
33+
active: true
34+
UnconditionalJumpStatementInLoop:
35+
active: true
36+
style:
37+
CascadingCallWrapping:
38+
active: true
39+
ClassOrdering:
40+
active: true
41+
EqualsOnSignatureLine:
42+
active: true
43+
BracesOnIfStatements:
44+
active: true
45+
MandatoryBracesLoops:
46+
active: true
47+
NoTabs:
48+
active: true
49+
NullableBooleanCheck:
50+
active: true
51+
SpacingBetweenPackageAndImports:
52+
active: true
53+
TrailingWhitespace:
54+
active: true
55+
UnderscoresInNumericLiterals:
56+
active: true
57+
UnnecessaryBackticks:
58+
active: true
59+
UntilInsteadOfRangeTo:
60+
active: true
61+
UnusedImports:
62+
active: true
63+
UseIfEmptyOrIfBlank:
64+
active: true

spotbugs/filter.xml renamed to dev_config/filter.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
<Match>
77
<Bug pattern="EI_EXPOSE_REP2"/>
88
</Match>
9+
<Match>
10+
<Source name="~.*\.kt"/>
11+
</Match>
912
</FindBugsFilter>

pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,23 @@
2323
<jaxbRuntimeVersion>4.0.4</jaxbRuntimeVersion>
2424
<jaxbCoreVersion>4.0.4</jaxbCoreVersion>
2525
<jaxbBuildHelperMavenPluginVersion>3.5.0</jaxbBuildHelperMavenPluginVersion>
26+
<kotlin.version>1.9.23</kotlin.version>
2627
</properties>
2728

2829
<build>
2930
<plugins>
3031

32+
<plugin>
33+
<groupId>org.jetbrains.kotlin</groupId>
34+
<artifactId>kotlin-maven-plugin</artifactId>
35+
<version>${kotlin.version}</version>
36+
<!-- You can set this option to automatically take information about lifecycles -->
37+
<extensions>true</extensions>
38+
<configuration>
39+
<jvmTarget>17</jvmTarget>
40+
</configuration>
41+
</plugin>
42+
3143
<plugin>
3244
<groupId>org.apache.maven.plugins</groupId>
3345
<artifactId>maven-compiler-plugin</artifactId>

sdccc/pom.xml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<spotbugsVersion>4.7.3</spotbugsVersion>
2121
<checkstyleConfigDir>../checkstyle</checkstyleConfigDir>
2222
<bouncyCastleVersion>1.67</bouncyCastleVersion>
23-
23+
<detektVersion>1.23.5</detektVersion>
2424
<!-- name of the directory inside the archive -->
2525
<jreDirectoryName>jdk-17.0.5+8-jre</jreDirectoryName>
2626
<jreBasePath>./jre</jreBasePath>
@@ -245,6 +245,25 @@
245245
<version>2.0.1</version>
246246
</dependency>
247247

248+
<!-- https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib -->
249+
<dependency>
250+
<groupId>org.jetbrains.kotlin</groupId>
251+
<artifactId>kotlin-stdlib</artifactId>
252+
<version>${kotlin.version}</version>
253+
</dependency>
254+
<!-- https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-test-junit5 -->
255+
<dependency>
256+
<groupId>org.jetbrains.kotlin</groupId>
257+
<artifactId>kotlin-test-junit5</artifactId>
258+
<version>${kotlin.version}</version>
259+
<scope>test</scope>
260+
</dependency>
261+
<!-- https://mvnrepository.com/artifact/com.lemonappdev/konsist -->
262+
<dependency>
263+
<groupId>com.lemonappdev</groupId>
264+
<artifactId>konsist</artifactId>
265+
<version>0.15.1</version>
266+
</dependency>
248267
</dependencies>
249268

250269
<reporting>
@@ -365,7 +384,7 @@
365384
</executions>
366385
<configuration>
367386
<includeTests>true</includeTests>
368-
<excludeFilterFile>../spotbugs/filter.xml</excludeFilterFile>
387+
<excludeFilterFile>${project.basedir}/../dev_config/filter.xml</excludeFilterFile>
369388
</configuration>
370389
</plugin>
371390

@@ -415,6 +434,31 @@
415434
</execution>
416435
</executions>
417436
</plugin>
437+
<plugin>
438+
<groupId>com.github.ozsie</groupId>
439+
<artifactId>detekt-maven-plugin</artifactId>
440+
<version>${detektVersion}</version>
441+
<configuration>
442+
<buildUponDefaultConfig>true</buildUponDefaultConfig>
443+
<config>${project.basedir}/../dev_config/detekt.yml</config>
444+
<report>html:${project.build.directory}/detekt.html</report>
445+
</configuration>
446+
<executions>
447+
<execution>
448+
<phase>verify</phase>
449+
<goals>
450+
<goal>check</goal>
451+
</goals>
452+
</execution>
453+
</executions>
454+
<dependencies>
455+
<dependency>
456+
<groupId>io.gitlab.arturbosch.detekt</groupId>
457+
<artifactId>detekt-formatting</artifactId>
458+
<version>${detektVersion}</version>
459+
</dependency>
460+
</dependencies>
461+
</plugin>
418462
</plugins>
419463
</build>
420464

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.draeger.medical.sdccc.architecture
2+
3+
import com.draeger.medical.sdccc.tests.annotations.TestDescription
4+
import com.draeger.medical.sdccc.tests.annotations.TestIdentifier
5+
import com.lemonappdev.konsist.api.Konsist
6+
import com.lemonappdev.konsist.api.ext.list.withAnnotationOf
7+
import com.lemonappdev.konsist.api.verify.assertTrue
8+
import org.junit.Test
9+
10+
/**
11+
* Checks the listed architectural rules for Kotlin.
12+
*/
13+
class KonsistArchitecturalRules {
14+
15+
@Test
16+
fun `requirement test classes in module 'sdccc' should end with 'Test'`() {
17+
checkNameOfRequirementTestClasses("sdccc")
18+
}
19+
20+
@Test
21+
fun `all requirement tests in module 'sdccc' should have annotations 'TestIdentifier' and 'TestDescription'`() {
22+
checkAnnotationsOfRequirementTests("sdccc")
23+
}
24+
25+
companion object {
26+
27+
fun checkNameOfRequirementTestClasses(moduleName: String, sourceSet: String = "main") {
28+
Konsist.scopeFromProject(moduleName = moduleName, sourceSetName = sourceSet).classes()
29+
.filter { it.resideInPackage("..direct..") || it.resideInPackage("..invariant..") }
30+
.assertTrue {
31+
it.name.endsWith("Test")
32+
}
33+
}
34+
35+
fun checkAnnotationsOfRequirementTests(
36+
moduleName: String,
37+
sourceSet: String = "main"
38+
) {
39+
Konsist.scopeFromProject(moduleName = moduleName, sourceSetName = sourceSet).functions()
40+
.filter { it.resideInPackage("..direct..") || it.resideInPackage("..invariant..") }
41+
.withAnnotationOf(org.junit.jupiter.api.Test::class)
42+
.assertTrue {
43+
it.hasAnnotationOf(TestIdentifier::class) && it.hasAnnotationOf(TestDescription::class)
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)