Skip to content
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

Setup detekt lint checks #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions HeaderTestModule/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,33 @@ plugins {
id("com.android.library")
id("com.chromaticnoise.multiplatform-swiftpackage") version "2.0.3"
id("kotlin-android-extensions")
// id("io.gitlab.arturbosch.detekt") version "1.17.1"
jacoco

}

version = "0.0.1"
group = "com.unidays.headertestmodule"

//detekt {
// buildUponDefaultConfig = true // preconfigure defaults
// allRules = false // activate all available (even unstable) rules.
// input = files("src/commonMain/kotlin")
// autoCorrect = false
//
// reports {
// html.enabled = true
// xml.enabled = true
// txt.enabled = true
// sarif.enabled = true
// }
//}
//
//tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
// // Target version of the generated JVM bytecode. It is used for type resolution.
// jvmTarget = "1.8"
//}

jacoco {
toolVersion = "0.8.6"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class HeaderBuilder {
const val TEST_HEADER_ID = 1
const val SOME_OTHER_HEADER = "Some other shit"
}
}
}
19 changes: 19 additions & 0 deletions KMPExampleModule/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,31 @@ plugins {
id("com.android.library")
id("com.chromaticnoise.multiplatform-swiftpackage") version "2.0.3"
id("kotlin-android-extensions")
id("io.gitlab.arturbosch.detekt") version "1.15.0"
jacoco
}

version = "0.0.1"
group = "com.example.kmpexamplemodule"

detekt {
buildUponDefaultConfig = true // preconfigure defaults
input = files("src/commonMain/kotlin")
autoCorrect = false

reports {
html.enabled = true
xml.enabled = true
txt.enabled = true
sarif.enabled = true
}
}

tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
// Target version of the generated JVM bytecode. It is used for type resolution.
jvmTarget = "1.8"
}

jacoco {
toolVersion = "0.8.6"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.example.kmpexamplemodule

actual class Platform actual constructor() {
actual val platform: String = "Android ${android.os.Build.VERSION.SDK_INT}"
actual val name: String = "Android ${android.os.Build.VERSION.SDK_INT}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class AndroidGreetingTest {

@Test
fun testExample() {
assertTrue("Check Android is mentioned", Greeting().greeting().contains("Android"))
assertTrue("Check Android is mentioned", Greeting().build().contains("Android"))
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.kmpexamplemodule

class Greeting {
fun greeting(): String {
return "Hello, ${Platform().platform}!"
fun build(): String {
return "Hello, ${Platform().name}!"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.example.kmpexamplemodule

/* we need to suppress this as the expect / actual keywords do not work without an empty constructor.
* those key words are still in beta so this should fix itself eventually */
@Suppress("EmptyDefaultConstructor")
expect class Platform() {
val platform: String
}
val name: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class CommonGreetingTest {

@Test
fun testExample() {
assertTrue(Greeting().greeting().contains("Hello"), "Check 'Hello' is mentioned")
assertTrue(Greeting().build().contains("Hello"), "Check 'Hello' is mentioned")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package com.example.kmpexamplemodule
import platform.UIKit.UIDevice

actual class Platform actual constructor() {
actual val platform: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
actual val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class IosGreetingTest {

@Test
fun testExample() {
assertTrue(Greeting().greeting().contains("iOS"), "Check iOS is mentioned")
assertTrue(Greeting().build().contains("iOS"), "Check iOS is mentioned")
}
}
7 changes: 7 additions & 0 deletions codemagic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ workflows:
- &install_java_15
name: Install Java 15.0.2
script: ./codeMagicScripts/installJava15.sh
- &run_static_analysis
name: Run Static Analysis
script: |
source ~/.bash_profile
export JAVA_HOME=$JAVA_LOCATION
./gradlew -Dorg.gradle.java.home=$JAVA_LOCATION build KMPExampleModule:detekt
- &run_unit_tests
name: Run Unit Tests
script: |
Expand Down Expand Up @@ -57,6 +63,7 @@ workflows:
source: true
scripts:
- *install_java_15
- *run_static_analysis
- *run_unit_tests
- *verify_tests_coverage
artifacts:
Expand Down