diff --git a/build.gradle.kts b/build.gradle.kts index 16f6e35a0..e96ff997b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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.* @@ -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 } } @@ -286,6 +276,28 @@ dependencies { detektPlugins(project(path = ":dispatch-detekt")) } +tasks.withType { + + 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 { + + 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 { diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 320b7fdbb..4ccc7c5de 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -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" diff --git a/dispatch-core/samples/test/samples/DefaultDispatcherProviderSample.kt b/dispatch-core/samples/test/samples/DefaultDispatcherProviderSample.kt index 24ada6f0c..a133b3e81 100644 --- a/dispatch-core/samples/test/samples/DefaultDispatcherProviderSample.kt +++ b/dispatch-core/samples/test/samples/DefaultDispatcherProviderSample.kt @@ -21,6 +21,7 @@ import kotlinx.coroutines.* import kotlinx.coroutines.test.* import org.junit.jupiter.api.* +@Suppress("HardCodedDispatcher") @ObsoleteCoroutinesApi @ExperimentalCoroutinesApi class DefaultDispatcherProviderSample { diff --git a/dispatch-core/src/main/java/dispatch/core/DefaultDispatcherProvider.kt b/dispatch-core/src/main/java/dispatch/core/DefaultDispatcherProvider.kt index a0202eabf..77821a38e 100644 --- a/dispatch-core/src/main/java/dispatch/core/DefaultDispatcherProvider.kt +++ b/dispatch-core/src/main/java/dispatch/core/DefaultDispatcherProvider.kt @@ -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 diff --git a/dispatch-detekt/build.gradle.kts b/dispatch-detekt/build.gradle.kts index 5f662234e..d284b3928 100644 --- a/dispatch-detekt/build.gradle.kts +++ b/dispatch-detekt/build.gradle.kts @@ -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) diff --git a/dispatch-detekt/src/test/java/dispatch/detekt/rules/AndroidxLifecycleScopeUsageTest.kt b/dispatch-detekt/src/test/java/dispatch/detekt/rules/AndroidxLifecycleScopeUsageTest.kt index 5fe3ed15e..d05c4c880 100644 --- a/dispatch-detekt/src/test/java/dispatch/detekt/rules/AndroidxLifecycleScopeUsageTest.kt +++ b/dispatch-detekt/src/test/java/dispatch/detekt/rules/AndroidxLifecycleScopeUsageTest.kt @@ -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 @@ -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 @@ -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") @@ -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 diff --git a/dispatch-detekt/src/test/java/dispatch/detekt/rules/HardCodedDispatcherUsageTest.kt b/dispatch-detekt/src/test/java/dispatch/detekt/rules/HardCodedDispatcherUsageTest.kt index 7273ea0d1..914906b55 100644 --- a/dispatch-detekt/src/test/java/dispatch/detekt/rules/HardCodedDispatcherUsageTest.kt +++ b/dispatch-detekt/src/test/java/dispatch/detekt/rules/HardCodedDispatcherUsageTest.kt @@ -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"), @@ -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"), @@ -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"), @@ -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(), diff --git a/dispatch-test-junit5/src/test/kotlin/dispatch/test/SetMainTest.kt b/dispatch-test-junit5/src/test/kotlin/dispatch/test/SetMainTest.kt index 4a35980cc..cc2d439e5 100644 --- a/dispatch-test-junit5/src/test/kotlin/dispatch/test/SetMainTest.kt +++ b/dispatch-test-junit5/src/test/kotlin/dispatch/test/SetMainTest.kt @@ -21,6 +21,7 @@ import kotlinx.coroutines.test.* import org.junit.jupiter.api.* import org.junit.jupiter.api.extension.* +@Suppress("HardCodedDispatcher") @ExperimentalCoroutinesApi class SetMainTest { diff --git a/dispatch-test/samples/test/samples/DefaultDispatcherProviderSample.kt b/dispatch-test/samples/test/samples/DefaultDispatcherProviderExtensionSample.kt similarity index 98% rename from dispatch-test/samples/test/samples/DefaultDispatcherProviderSample.kt rename to dispatch-test/samples/test/samples/DefaultDispatcherProviderExtensionSample.kt index cc1759c32..37a7c80e9 100644 --- a/dispatch-test/samples/test/samples/DefaultDispatcherProviderSample.kt +++ b/dispatch-test/samples/test/samples/DefaultDispatcherProviderExtensionSample.kt @@ -22,6 +22,7 @@ import kotlinx.coroutines.* import kotlinx.coroutines.test.* import org.junit.jupiter.api.* +@Suppress("HardCodedDispatcher") @ObsoleteCoroutinesApi @ExperimentalCoroutinesApi class DefaultDispatcherProviderExtensionSample { diff --git a/dispatch-test/src/test/kotlin/dispatch/test/BuildersTest.kt b/dispatch-test/src/test/kotlin/dispatch/test/BuildersTest.kt index 3171dcb1d..d732dc07d 100644 --- a/dispatch-test/src/test/kotlin/dispatch/test/BuildersTest.kt +++ b/dispatch-test/src/test/kotlin/dispatch/test/BuildersTest.kt @@ -23,6 +23,7 @@ import kotlinx.coroutines.test.* import org.junit.jupiter.api.* import kotlin.coroutines.* +@Suppress("HardCodedDispatcher") @ExperimentalCoroutinesApi internal class BuildersTest { diff --git a/dispatch-test/src/test/kotlin/dispatch/test/TestDispatcherProviderTest.kt b/dispatch-test/src/test/kotlin/dispatch/test/TestDispatcherProviderTest.kt index 0c4be0fe4..3cebb8a71 100644 --- a/dispatch-test/src/test/kotlin/dispatch/test/TestDispatcherProviderTest.kt +++ b/dispatch-test/src/test/kotlin/dispatch/test/TestDispatcherProviderTest.kt @@ -22,6 +22,7 @@ import kotlinx.coroutines.test.* import org.junit.jupiter.api.* import java.util.concurrent.atomic.* +@Suppress("HardCodedDispatcher") @ExperimentalCoroutinesApi internal class TestDispatcherProviderTest {