Zurück zum Ranking

detekt/detekt

MDXdetekt.dev

Static code analysis for Kotlin

staticanalysiskotlincodesmellslintergradle-pluginstatic-analysislintcode-qualityhacktoberfest
Sterne-Wachstum
Sterne
7k
Forks
847
Wochenwachstum
Issues
174
2k4k6k
Okt. 2016Jan. 2020Apr. 2023Juli 2026
README

detekt

Join the chat at #detekt on KotlinLang Visit the website at detekt.dev/ Maven Central Gradle Plugin Revved up by Develocity License

Pre Merge Checks Codecov Awesome Kotlin Badge FOSSA Status

Meet detekt, a static code analysis tool for the Kotlin programming language. Visit the project website for installation guides, rule descriptions, configuration options and more.

detekt in action

Features

  • Code smell analysis for your Kotlin projects.
  • Highly configurable rule sets.
  • Generate baselines to suppress existing issues for legacy projects while making sure no new issues are introduced.
  • Suppress issues in source files using @Suppress annotations.
  • Support for different report formats: HTML, Markdown, SARIF, XML (Checkstyle) and custom reports.
  • Extend detekt with custom rule sets and reports.
  • Complexity reports based on lines of code, cyclomatic complexity and number of code smells.
  • First party integration with Gradle with our Gradle plugin.
  • A community of third party plugins that adds more rules and features to detekt.

Quick-Links

Quick Start ...

with the command-line interface

curl -sSLO https://github.com/detekt/detekt/releases/download/v[version]/detekt-cli-[version]-all.jar
java -jar detekt-cli-[version]-all.jar --help

You can find other ways to install detekt here

with Gradle

plugins {
    id("io.gitlab.arturbosch.detekt") version "[version]"
}

repositories {
    mavenCentral()
}

detekt {
    buildUponDefaultConfig = true // preconfigure defaults
    allRules = false // activate all available (even unstable) rules.
    config.setFrom("$projectDir/config/detekt.yml") // point to your custom config defining rules to run, overwriting default behavior
    baseline = file("$projectDir/config/baseline.xml") // a way of suppressing issues before introducing detekt
}

tasks.withType<Detekt>().configureEach {
    reports {
        html.required.set(true) // observe findings in your browser with structure and code snippets
        checkstyle.required.set(true) // checkstyle(xml) like format mainly for integrations like Jenkins
        sarif.required.set(true) // standardized SARIF format (https://sarifweb.azurewebsites.net/) to support integrations with GitHub Code Scanning
        markdown.required.set(true) // simple Markdown format
    }
}

// Groovy DSL
tasks.withType(Detekt).configureEach {
    jvmTarget = "1.8"
}
tasks.withType(DetektCreateBaselineTask).configureEach {
    jvmTarget = "1.8"
}

// or

// Kotlin DSL
tasks.withType<Detekt>().configureEach {
    jvmTarget = "1.8"
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
    jvmTarget = "1.8"
}

See maven central for releases and sonatype for snapshots.

If you want to use a SNAPSHOT version, you can find more info on this documentation page.

Requirements

Executing detekt

Gradle 6.8.3+ is the minimum requirement. However, the recommended versions together with the other tools recommended versions are:

Detekt Version Gradle Kotlin AGP Java Target Level JDK Max Version
2.0.0-alpha.5 9.5.1 2.4.0 9.2.1 1.8 25
2.0.0-alpha.3 9.3.1 2.3.21 9.1.1 1.8 25
2.0.0-alpha.2 9.3.0 2.3.0 9.0.0 1.8 25
2.0.0-alpha.1 9.1.0 2.2.20 8.13.0 1.8 25
2.0.0-alpha.0 8.13.0 2.2.10 8.13.0 1.8 21
1.23.8 8.12.1 2.0.21 8.8.1 1.8 21

The list of recommended versions for previous detekt version is listed here.

Building detekt

Java 17 or higher is required to build detekt.

Adding more rule sets

detekt itself provides a wrapper over ktlint as the ktlint rule set which can be easily added to the Gradle configuration:

dependencies {
    detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-ktlint-wrapper:[version]")
}

Similarly, there are extra rule sets available for detekt from detekt:

dependencies {
    detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-libraries:[version]")
    detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-ruleauthors:[version]")
}

For more info visit the Detekt Marketplace.

Likewise custom extensions can be added to detekt.

Contributing

See CONTRIBUTING

Thanks to all the people who contributed to detekt!

Profile images of all the contributors

Mentions

androidweekly androidweekly

As mentioned in...

Integrations:

Custom rules and reports from 3rd parties can be found on our Detekt Marketplace.

Credits

Ähnliche Repositories
vercel/next.js

The React Framework

JavaScriptnpmMIT Licensereactserver-rendering
nextjs.org
141.1k31.5k
withastro/astro

The web framework for content-driven websites. ⭐️ Star to support our work!

TypeScriptnpmOtherstatic-site-generatorblog
astro.build
61.2k3.6k
decaporg/decap-cms

A Git-based CMS for Static Site Generators

JavaScriptnpmMIT Licensecmsjamstack
decapcms.org
19.3k3.1k
getzola/zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org

Rustcrates.ioEuropean Union Public License 1.2staticsite-generator
getzola.org
17.3k1.2k
http-party/http-server

A simple, zero-configuration, command-line http server

JavaScriptnpmMIT Licensehttpstatic
14.2k1.6k
react-static/react-static

⚛️ 🚀 A progressive static site generator for React.

JavaScriptnpmMIT Licensereactreact-static
github.com/react-static/react-static/discussions
10.3k742
apex/up

Deploy infinitely scalable serverless apps, apis, and sites in seconds to AWS.

GoGo ModulesMIT Licensedeploymentaws
up.docs.apex.sh
8.8k385
robinmoisson/staticrypt

Password protect a static HTML page, decrypted in-browser in JS with no dependency. No server logic needed.

HTMLMIT Licensestatic-htmlencryption
robinmoisson.github.io/staticrypt/
8k495
carp-lang/Carp

A statically typed lisp, without a GC, for real-time applications.

HaskellApache License 2.0lisplanguage
6k185
nunomaduro/phpinsights

🔰 Instant PHP quality checks from your console

PHPPackagistMIT Licensephpstatic
youtube.com/@nunomaduro
5.6k296
saicaca/fuwari

✨A static blog template built with Astro.

AstroMIT Licenseastroblog
fuwari.vercel.app
4.8k1.2k
JamesIves/github-pages-deploy-action

🚀 Automatically deploy your project to GitHub Pages using GitHub Actions. This action can be configured to push your production-ready code into any branch you'd like.

TypeScriptnpmMIT Licensegithub-actionsgithub-action
github.com/marketplace/actions/deploy-to-github-pages
4.6k431