Cleaned up tests
This commit is contained in:
parent
a13a2b814b
commit
133d996029
4 changed files with 14 additions and 19 deletions
|
@ -10,8 +10,7 @@
|
||||||
|
|
||||||
To install, please refer to the [extensions documentation](https://github.com/rife2/bld/wiki/Extensions).
|
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
|
```java
|
||||||
@BuildCommand(summary = "Checks source with Detekt")
|
@BuildCommand(summary = "Checks source with Detekt")
|
||||||
public void detekt() throws ExitStatusException, IOException, InterruptedException {
|
public void detekt() throws ExitStatusException, IOException, InterruptedException {
|
||||||
|
|
|
@ -1,27 +1,22 @@
|
||||||
package com.example
|
package com.example
|
||||||
|
|
||||||
class Example {
|
class Example {
|
||||||
val message: String
|
// https://detekt.dev/docs/rules/naming#variablenaming
|
||||||
|
val Message: String
|
||||||
get() = "Hello World!"
|
get() = "Hello World!"
|
||||||
|
|
||||||
// https://detekt.dev/docs/1.22.0/rules/performance#arrayprimitive
|
// https://detekt.dev/docs/rules/style/#magicnumber
|
||||||
fun returningFunction(): Array<Double> { return arrayOf() }
|
val foo = 5
|
||||||
|
|
||||||
// https://detekt.dev/docs/1.22.0/rules/style#canbenonnullable
|
|
||||||
fun foo(a: Int?) {
|
|
||||||
val b = a!! + 2
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
// https://detekt.dev/docs/1.22.0/rules/naming#booleanpropertynaming
|
println(Example().Message)
|
||||||
val progressBar: Boolean = true
|
// https://detekt.dev/docs/rules/empty-blocks#emptyifblock
|
||||||
// https://detekt.dev/docs/1.22.0/rules/potential-bugs#avoidreferentialequality
|
if (true) {
|
||||||
val areEqual = "aString" === ""
|
} else {
|
||||||
println(Example().message)
|
// https://detekt.dev/docs/rules/exceptions#throwingexceptionswithoutmessageorcause
|
||||||
if (false) {
|
// https://detekt.dev/docs/rules/style/#usecheckorerror
|
||||||
// https://detekt.dev/docs/1.22.0/rules/exceptions#exceptionraisedinunexpectedlocation
|
|
||||||
throw IllegalStateException()
|
throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@ import kotlin.test.assertEquals
|
||||||
class ExampleTest {
|
class ExampleTest {
|
||||||
@Test
|
@Test
|
||||||
fun verifyHello() {
|
fun verifyHello() {
|
||||||
assertEquals("Hello World!", Example().message)
|
assertEquals("Hello World!", Example().Message)
|
||||||
}
|
}
|
||||||
} // https://detekt.dev/docs/1.22.0/rules/empty-blocks#emptyfunctionblock
|
} // https://detekt.dev/docs/1.22.0/rules/empty-blocks#emptyfunctionblock
|
|
@ -49,7 +49,8 @@ class DetektOperationTest {
|
||||||
void testExamplesExecute() {
|
void testExamplesExecute() {
|
||||||
var op = new DetektOperation()
|
var op = new DetektOperation()
|
||||||
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
|
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
|
||||||
"Example"));
|
"Example"))
|
||||||
|
.debug(true);
|
||||||
assertThatThrownBy(op::execute).isInstanceOf(ExitStatusException.class);
|
assertThatThrownBy(op::execute).isInstanceOf(ExitStatusException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue