Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Detekt 1.14.1 #168

Merged
merged 1 commit into from
Oct 4, 2020
Merged
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
44 changes: 28 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress("MagicNumber")

import formatting.sortDependencies
import formatting.*
import io.gitlab.arturbosch.detekt.*
import kotlinx.knit.*
import kotlinx.validation.*
Expand Down Expand Up @@ -259,25 +258,16 @@ val copyRootFiles by tasks.registering {
}
}

@Suppress("DEPRECATION")
detekt {

parallel = true
config = files("$rootDir/detekt/detekt-config.yml")

val unique = "${rootProject.relativePath(projectDir)}/${project.name}"

reports {
xml {
enabled = false
destination = file("$rootDir/build/detekt-reports/$unique-detekt.xml")
}
html {
enabled = true
destination = file("$rootDir/build/detekt-reports/$unique-detekt.html")
}
txt {
enabled = false
destination = file("$rootDir/build/detekt-reports/$unique-detekt.txt")
}
xml.enabled = false
html.enabled = true
txt.enabled = false
}
}

Expand All @@ -286,6 +276,28 @@ dependencies {
detektPlugins(project(path = ":dispatch-detekt"))
}

tasks.withType<DetektCreateBaselineTask> {

setSource(files(rootDir))

include("**/*.kt", "**/*.kts")
exclude("**/resources/**", "**/build/**", "**/src/test/java**")

// Target version of the generated JVM bytecode. It is used for type resolution.
this.jvmTarget = "1.8"
}

tasks.withType<Detekt> {

setSource(files(rootDir))

include("**/*.kt", "**/*.kts")
exclude("**/resources/**", "**/build/**", "**/src/test/java**")

// Target version of the generated JVM bytecode. It is used for type resolution.
this.jvmTarget = "1.8"
}

apply(plugin = Plugins.binaryCompatilibity)

extensions.configure<ApiValidationExtension> {
Expand Down
6 changes: 5 additions & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ object Libs {
}

object Detekt {
const val version = "1.10.0"
/*
TODO - When updating, check to see if Spek and AssertJ can be removed from :detekt:extensions
https://github.com/detekt/detekt/issues/3082
*/
const val version = "1.14.1"
const val api = "io.gitlab.arturbosch.detekt:detekt-api:$version"
const val cli = "io.gitlab.arturbosch.detekt:detekt-cli:$version"
const val formatting = "io.gitlab.arturbosch.detekt:detekt-formatting:$version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import kotlinx.coroutines.*
import kotlinx.coroutines.test.*
import org.junit.jupiter.api.*

@Suppress("HardCodedDispatcher")
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
class DefaultDispatcherProviderSample {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ object DefaultDispatcherProvider {
*/
@Deprecated(
message = "The DefaultDispatcherProvider class has been replaced with this singleton object. " +
"To create a DispatcherProvider with the default implementation, use the DispatcherProvider companion object factory. " +
"To create a DispatcherProvider with the default implementation," +
" use the DispatcherProvider companion object factory. " +
"This function will be removed before the 1.0 release.",
replaceWith = ReplaceWith("DispatcherProvider()"),
level = DeprecationLevel.HIDDEN
Expand Down
5 changes: 5 additions & 0 deletions dispatch-detekt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ dependencies {
implementation(Libs.Detekt.api)
implementation(Libs.Kotlin.stdlib)

// detekt-test leaks transitive dependencies upon AssertJ and Spek
// https://github.com/detekt/detekt/issues/3082
testImplementation("org.assertj:assertj-core:3.17.2")
testImplementation("org.spekframework.spek2:spek-dsl-jvm:2.0.13")

testImplementation(Libs.Detekt.api)
testImplementation(Libs.Detekt.test)
testImplementation(Libs.JUnit.jUnit5Api)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import io.kotest.matchers.*
internal class AndroidXLifecycleScopeTest : FreeSpec(
{

"importing androidx lifecycleScope and using it should report Finding" - {
"importing androidx lifecycleScope and using it should report Finding" {

val text = """
|package a.b.c
Expand All @@ -48,7 +48,7 @@ internal class AndroidXLifecycleScopeTest : FreeSpec(
)
}

"importing androidx lifecycleScope without using it should NOT report Finding" - {
"importing androidx lifecycleScope without using it should NOT report Finding" {

val text = """
|package a.b.c
Expand All @@ -68,14 +68,14 @@ internal class AndroidXLifecycleScopeTest : FreeSpec(
findings shouldBe listOf()
}

"issue id should be AndroidXLifecycleScope" - {
"issue id should be AndroidXLifecycleScope" {

val rule = AndroidXLifecycleScope()

rule.issue.id shouldBe "AndroidXLifecycleScope"
}

"issue should not be reported if suppressing AndroidXLifecycleScope" - {
"issue should not be reported if suppressing AndroidXLifecycleScope" {

val text = """
|@file:Suppress("AndroidXLifecycleScope")
Expand All @@ -100,7 +100,7 @@ internal class AndroidXLifecycleScopeTest : FreeSpec(
findings shouldBe listOf()
}

"using Dispatch lifecycleScope should not report Finding" - {
"using Dispatch lifecycleScope should not report Finding" {

val text = """
|package a.b.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class HardCodedDispatcherTest : FreeSpec(
fun findingMessage(expression: String) =
"Using Dispatchers singleton reference (`$expression`) instead of a DispatcherProvider property."

"positive cases" - {
"positive cases" {

forAll(
row("import kotlinx.coroutines.Dispatchers.Default", "Default"),
Expand Down Expand Up @@ -79,7 +79,7 @@ internal class HardCodedDispatcherTest : FreeSpec(
}
}

"importing without using it should not report finding" - {
"importing without using it should not report finding" {

forAll(
row("import kotlinx.coroutines.Dispatchers.Default"),
Expand Down Expand Up @@ -125,14 +125,14 @@ internal class HardCodedDispatcherTest : FreeSpec(
}
}

"issue id should be AndroidXLifecycleScope" - {
"issue id should be AndroidXLifecycleScope" {

val rule = HardCodedDispatcher()

rule.issue.id shouldBe "HardCodedDispatcher"
}

"issue should not be reported if suppressing HardCodedDispatcher" - {
"issue should not be reported if suppressing HardCodedDispatcher" {

forAll(
row("import kotlinx.coroutines.Dispatchers.Default", "Default"),
Expand Down Expand Up @@ -185,7 +185,7 @@ internal class HardCodedDispatcherTest : FreeSpec(
}
}

"allowing a dispatcher should mean its usage is not reported" - {
"allowing a dispatcher should mean its usage is not reported" {

checkAll(
Exhaustive.boolean(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import kotlinx.coroutines.test.*
import org.junit.jupiter.api.*
import org.junit.jupiter.api.extension.*

@Suppress("HardCodedDispatcher")
@ExperimentalCoroutinesApi
class SetMainTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import kotlinx.coroutines.*
import kotlinx.coroutines.test.*
import org.junit.jupiter.api.*

@Suppress("HardCodedDispatcher")
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
class DefaultDispatcherProviderExtensionSample {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import kotlinx.coroutines.test.*
import org.junit.jupiter.api.*
import kotlin.coroutines.*

@Suppress("HardCodedDispatcher")
@ExperimentalCoroutinesApi
internal class BuildersTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import kotlinx.coroutines.test.*
import org.junit.jupiter.api.*
import java.util.concurrent.atomic.*

@Suppress("HardCodedDispatcher")
@ExperimentalCoroutinesApi
internal class TestDispatcherProviderTest {

Expand Down