Run detekt on all test sources (#3010)

* Fix formatting issues

* Run detekt also on test sources
This commit is contained in:
Artur Bosch
2020-08-24 14:57:47 +02:00
committed by GitHub
parent 0fc25c49cb
commit 282c038c2e
7 changed files with 25 additions and 19 deletions

View File

@@ -1,5 +1,6 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
plugins {
id("io.gitlab.arturbosch.detekt")
@@ -26,6 +27,12 @@ subprojects {
}
detekt {
input = objects.fileCollection().from(
DetektExtension.DEFAULT_SRC_DIR_JAVA,
"src/test/java",
DetektExtension.DEFAULT_SRC_DIR_KOTLIN,
"src/test/kotlin"
)
buildUponDefaultConfig = true
baseline = baselineFile

View File

@@ -238,7 +238,7 @@ object IgnoredReturnValueSpec : Spek({
"""
val findings = subject.compileAndLintWithContext(env, code)
assertThat(findings).hasSize(1)
assertThat(findings).hasSourceLocation(11,10)
assertThat(findings).hasSourceLocation(11, 10)
}
it("reports when a function which returns a value is called before a semicolon") {

View File

@@ -7,7 +7,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object NullableToStringCallSpec: Spek({
object NullableToStringCallSpec : Spek({
setupKotlinEnvironment()
val env: KotlinCoreEnvironment by memoized()

View File

@@ -49,7 +49,7 @@ class UnnecessaryApplySpec : Spek({
}
it("reports a false negative apply on nullable type - #1485") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
val a: Any? = Any()
fun Any.b() = Unit
@@ -62,7 +62,7 @@ class UnnecessaryApplySpec : Spek({
}
it("does not report an apply with lambda block") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
fun f() {
val a: Int? = null
a?.apply({
@@ -73,7 +73,7 @@ class UnnecessaryApplySpec : Spek({
}
it("does not report single statement in apply used as function argument") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
fun b(i: Int?) {}
fun main() {
@@ -86,7 +86,7 @@ class UnnecessaryApplySpec : Spek({
}
it("does not report single assignment statement in apply used as function argument - #1517") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
class C {
var prop = 0
}
@@ -118,7 +118,7 @@ class UnnecessaryApplySpec : Spek({
}
it("does not report applies with lambda body containing more than one statement") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
fun b(i: Int?) {}
fun main() {
@@ -143,7 +143,7 @@ class UnnecessaryApplySpec : Spek({
context("reported false positives - #1305") {
it("is used within an assignment expr itself") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
class C {
fun f() = true
}
@@ -153,7 +153,7 @@ class UnnecessaryApplySpec : Spek({
}
it("is used as return type of extension function") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
class C(var prop: Int)
fun Int.f() = C(5).apply { prop = 10 }
@@ -161,7 +161,7 @@ class UnnecessaryApplySpec : Spek({
}
it("should not flag apply when assigning property on this") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
class C(var prop: Int) {
private val c by lazy {
C(1).apply { prop = 3 }
@@ -171,7 +171,7 @@ class UnnecessaryApplySpec : Spek({
}
it("should not report apply when using it after returning something") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
class C(var prop: Int)
fun f() = (C(5)).apply { prop = 10 }
@@ -179,7 +179,7 @@ class UnnecessaryApplySpec : Spek({
}
it("should not report apply usage inside safe chained expressions") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
fun f() {
val arguments = listOf(1,2,3)
?.map { it * 2 }
@@ -193,7 +193,7 @@ class UnnecessaryApplySpec : Spek({
context("false positive in single nesting expressions - #1473") {
it("should not report the if expression") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
class C {
fun has() = true
}
@@ -209,7 +209,7 @@ class UnnecessaryApplySpec : Spek({
}
it("should report reference expressions") {
assertThat(subject.compileAndLintWithContext(env,"""
assertThat(subject.compileAndLintWithContext(env, """
class C {
val prop = 5
}

View File

@@ -59,7 +59,7 @@ class UnnecessaryLetSpec : Spek({
assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET }
}
it("reports unnecessary lets that can be changed to ordinary method call 5" ) {
it("reports unnecessary lets that can be changed to ordinary method call 5") {
val findings = subject.compileAndLintWithContext(env, """
fun f() {
val a: Int = 1

View File

@@ -20,7 +20,7 @@ class UnusedPrivateClassSpec : Spek({
val findings = subject.compileAndLint(code)
assertThat(findings).hasSize(1)
assertThat(findings).hasSourceLocation(1,1)
assertThat(findings).hasSourceLocation(1, 1)
}
describe("top level private classes") {
@@ -34,7 +34,7 @@ class UnusedPrivateClassSpec : Spek({
val findings = subject.compileAndLint(code)
assertThat(findings).hasSize(1)
assertThat(findings).hasSourceLocation(1,1)
assertThat(findings).hasSourceLocation(1, 1)
}
it("should not report them if used as parent") {
@@ -46,7 +46,7 @@ class UnusedPrivateClassSpec : Spek({
val findings = subject.compileAndLint(code)
assertThat(findings).hasSize(1)
assertThat(findings).hasSourceLocation(2,1)
assertThat(findings).hasSourceLocation(2, 1)
}
it("should not report them used as generic parent type") {

View File

@@ -22,7 +22,6 @@ import org.kohsuke.github.GitHub
import java.io.File
import java.net.URL
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
class GithubMilestoneReport : CliktCommand() {