diff --git a/README.md b/README.md index 298c2c0..9692081 100755 --- a/README.md +++ b/README.md @@ -10,8 +10,7 @@ To install, please refer to the [extensions documentation](https://github.com/rife2/bld/wiki/Extensions). -To check all Kotlin source code located `src/main/kotlin` and `src/test/kotlin`, add the following to your build file - +To check all Kotlin source code located `src/main/kotlin` and `src/test/kotlin`, add the following to your build file: ```java @BuildCommand(summary = "Checks source with Detekt") public void detekt() throws ExitStatusException, IOException, InterruptedException { diff --git a/examples/src/main/kotlin/com/example/Example.kt b/examples/src/main/kotlin/com/example/Example.kt index 34182e6..0a744e4 100644 --- a/examples/src/main/kotlin/com/example/Example.kt +++ b/examples/src/main/kotlin/com/example/Example.kt @@ -1,27 +1,22 @@ package com.example class Example { - val message: String + // https://detekt.dev/docs/rules/naming#variablenaming + val Message: String get() = "Hello World!" - // https://detekt.dev/docs/1.22.0/rules/performance#arrayprimitive - fun returningFunction(): Array { return arrayOf() } - - // https://detekt.dev/docs/1.22.0/rules/style#canbenonnullable - fun foo(a: Int?) { - val b = a!! + 2 - } + // https://detekt.dev/docs/rules/style/#magicnumber + val foo = 5 companion object { @JvmStatic fun main(args: Array) { - // https://detekt.dev/docs/1.22.0/rules/naming#booleanpropertynaming - val progressBar: Boolean = true - // https://detekt.dev/docs/1.22.0/rules/potential-bugs#avoidreferentialequality - val areEqual = "aString" === "" - println(Example().message) - if (false) { - // https://detekt.dev/docs/1.22.0/rules/exceptions#exceptionraisedinunexpectedlocation + println(Example().Message) + // https://detekt.dev/docs/rules/empty-blocks#emptyifblock + if (true) { + } else { + // https://detekt.dev/docs/rules/exceptions#throwingexceptionswithoutmessageorcause + // https://detekt.dev/docs/rules/style/#usecheckorerror throw IllegalStateException() } } diff --git a/examples/src/test/kotlin/com/example/ExampleTest.kt b/examples/src/test/kotlin/com/example/ExampleTest.kt index e8c53ae..0c6a966 100644 --- a/examples/src/test/kotlin/com/example/ExampleTest.kt +++ b/examples/src/test/kotlin/com/example/ExampleTest.kt @@ -6,6 +6,6 @@ import kotlin.test.assertEquals class ExampleTest { @Test fun verifyHello() { - assertEquals("Hello World!", Example().message) + assertEquals("Hello World!", Example().Message) } } // https://detekt.dev/docs/1.22.0/rules/empty-blocks#emptyfunctionblock \ No newline at end of file diff --git a/src/test/java/rife/bld/extension/DetektOperationTest.java b/src/test/java/rife/bld/extension/DetektOperationTest.java index d22704d..a66ec11 100644 --- a/src/test/java/rife/bld/extension/DetektOperationTest.java +++ b/src/test/java/rife/bld/extension/DetektOperationTest.java @@ -49,7 +49,8 @@ class DetektOperationTest { void testExamplesExecute() { var op = new DetektOperation() .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", - "Example")); + "Example")) + .debug(true); assertThatThrownBy(op::execute).isInstanceOf(ExitStatusException.class); }