A static code analyzer for Kotlin
open sourceApache-2.0free
detekt is a static code analysis tool for Kotlin that finds code smells and complexity problems with configurable rule sets. It runs from the command line or through its own Gradle plugin, works on Android, JVM, JS, Native and Multiplatform projects, and writes reports in HTML, Markdown, SARIF and Checkstyle XML. A baseline file suppresses existing issues in a legacy codebase so only new ones fail the build, and teams can add custom rule sets and reports. It is open source under Apache-2.0 and developed by the community; 2.0 is in pre-release alongside the stable 1.x line.
Ways to install
Package managers
Problems it solves
- find code smells and overly complex functions in my Kotlin codebase
- fail my Gradle build when new Kotlin code breaks our style rules without fixing every old issue first
- upload Kotlin static analysis results to GitHub code scanning
Features
- code smell and complexity analysis for Kotlin
- highly configurable rule sets
- baseline files to suppress existing issues in legacy projects
- suppress findings with @Suppress annotations
- HTML, Markdown, SARIF, Checkstyle XML and custom reports
- custom rule sets and report extensions
- first-party Gradle plugin and a command-line interface
Alternatives
The same job
These do what detekt does.
- SwiftLint Linter that enforces Swift style and conventions, with auto-fix
- KubeLinter Static analysis for Kubernetes YAML files and Helm charts
- PHPMD PHP Mess Detector: finds bugs and code smells in PHP
- ansible-lint Checks playbooks for practices and behavior that could potentially be improved