Skip to content

pkware/detektExtensions

Repository files navigation

detektExtensions

This project contains extensions for the Detekt linter written in Kotlin. See Extending Detekt for more information.

The following Detekt rule extensions have been written for the Detekt linter:

  • EnforceStaticImport-
    • This rule extension looks for methods that should be statically imported and issues a code smell if they are found.
    • The extension requires that the classpath of Detekt be set properly to provide a binding context for the methods that should be statically imported.
      • See Detekt Type Resolution for details
      • Examples of setting the classpath of detekt within build.gradle.kts are:
      tasks.withType<Detekt>().configureEach {
          val paths = mutableListOf(
                  project.configurations.getByName("detekt")
              )
          classpath.setFrom(paths)
      }
      or
      tasks.withType<Detekt>().configureEach {
          dependsOn("detektMain", "detektTest")
      }
    • Rule configuration can be done in the detekt.yml file under the import set of rules.

In order to import this extension into your project that is also using detekt do the following:

  • ensure your settings.gradle.kts file can pull dependencies from maven central.
dependencyResolutionManagement {
    repositories {
        mavenCentral()
    }
}
  • in your top level build.gradle.kts file you need to let detekt know about the extension.
dependencies {
    detektPlugins("com.pkware.detekt:import-extension:x.y")
}
  • Where x.y corresponds to the version of this detekt-extensions defined in the gradle.properties file of this project.
  • in your detekt.yml config file add the following code to enable the extension:
import:
  EnforceStaticImport:
    active: true
    methods:
      - 'com.google.common.truth.Truth.assertThat'
      - 'org.junit.jupiter.params.provider.Arguments.arguments'

Releasing

Releases are automated via release-please. As feat and fix commits accumulate on main, release-please maintains an open release PR that updates CHANGELOG.md and bumps the version in gradle.properties. Merging that PR causes release-please to push a semver tag, which triggers the publish workflow to sign and publish artifacts to Maven Central and create a GitHub Release with auto-generated release notes.

Every push to main also publishes the current -SNAPSHOT version to the Maven Central snapshot repository at central.sonatype.com/repository/maven-snapshots/.

About

Extensions for the Detekt Linter

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages