• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

detekt/detekt: Static code analysis for Kotlin

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

detekt/detekt

开源软件地址(OpenSource Url):

https://github.com/detekt/detekt

开源编程语言(OpenSource Language):

Kotlin 99.0%

开源软件介绍(OpenSource Introduction):

detekt

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

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.
  • Code Smell baseline and suppression for legacy projects.
  • Suppression of findings with @Suppress annotations.
  • Support for different report formats: html, markdown, SARIF and xml (checkstyle). Is it not enough? You can extend detekt and create your own reports.
  • Extensibility by enabling incorporation of personal rule sets, FileProcessListener's and OutputReport's.
  • 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 = files("$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
        xml.required.set(true) // checkstyle like format mainly for integrations like Jenkins
        txt.required.set(true) // similar to the console output, contains issue signature to manually edit baseline files
        sarif.required.set(true) // standardized SARIF format (https://sarifweb.azurewebsites.net/) to support integrations with Github Code Scanning
        md.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

Gradle 6.1+ 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
1.20.0 7.4.2 1.6.20 7.1.3 1.8 17

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

Adding more rule sets

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

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

Likewise custom extensions can be added to detekt.

Contributing

See CONTRIBUTING

Thanks to all the people who contributed to detekt!

Mentions

androidweekly androidweekly

As mentioned in...

Integrations:

Custom rules and reports from 3rd parties:

Credits




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap