Apache License 2.0

项目介绍

vanniktech/gradle-code-quality-tools-plugin 是一个托管在 GitHub 上的开源项目,主要使用 Kotlin 编写,采用 Apache License 2.0 许可证,目前获得 358 个 Star、26 次 Fork。

仓库全名
vanniktech/gradle-code-quality-tools-plugin
开源许可证
Apache License 2.0
Star 数
358
Fork 数
26
未关闭 Issue
6

README 摘要

gradle-code-quality-tools-plugin Gradle plugin that configures Checkstyle, PMD, CPD, Lint & Ktlint. All of these tools are also automatically hooked into the check gradle task. Below, I'll go more into depth how each of those plugins are configured. This plugin requires Gradle 5.0 or later. Set up root/build.gradle Snapshot Configuration The philosophy of this plugin is to fail early. This means having zero warnings…

完整内容见 GitHub 原始 README 或本页 。

常见问题

gradle-code-quality-tools-plugin 用什么语言开发?

主要使用 Kotlin 编写,采用 Apache License 2.0 许可证,目前有 358 个 Star。

gradle-code-quality-tools-plugin 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 gradle-code-quality-tools-plugin 的源码?

可以直接克隆仓库:git clone https://github.com/vanniktech/gradle-code-quality-tools-plugin.git,默认分支为 master;安装与运行步骤见仓库 README。

gradle-code-quality-tools-plugin 最近还在维护吗?

仓库最近一次更新为 6月22日,当前有 6 个未关闭 Issue;Star 数为 358,可作为社区活跃度的参考。

关于

Gradle plugin that generates Checkstyle, PMD, CPD, Lint & Ktlint Tasks for every subproject.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
768
价值分
258
活跃状态
活跃

语言占比

Kotlin
Shell

Release

README

gradle-code-quality-tools-plugin

Gradle plugin that configures Checkstyle, PMD, CPD, Lint & Ktlint. All of these tools are also automatically hooked into the check gradle task. Below, I’ll go more into depth how each of those plugins are configured.

This plugin requires Gradle 5.0 or later.

Set up

root/build.gradle

buildscript {
  repositories {
    mavenCentral()
    google()
  }
  dependencies {
    classpath "com.vanniktech:gradle-code-quality-tools-plugin:0.25.0"
  }
}

apply plugin: "com.vanniktech.code.quality.tools"

Snapshot

buildscript {
  repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
  }
  dependencies {
    classpath "com.vanniktech:gradle-code-quality-tools-plugin:0.26.0-SNAPSHOT"
  }
}

apply plugin: "com.vanniktech.code.quality.tools"

Configuration

The philosophy of this plugin is to fail early. This means having zero warnings / errors reported from any tools. If you’re just getting started with this in a large code base you might not be able to achieve this right away in which case you might want to set failEarly to false and then apply at a finer more granular scope how each tool should behave e.g. checkstyle { ignoreFailures = false }.

Those are all the available configurations - shown with default values and their types. More information can be found in the Kotlin Documentation of the Extension and the respective extensions for designated integrations.

codeQualityTools {
  boolean failEarly = true
  boolean xmlReports = true
  boolean htmlReports = false
  boolean textReports = false
  String[] ignoreProjects = []

  checkstyle {
    boolean enabled = true
    String toolVersion = '8.6'
    String configFile = 'code_quality_tools/checkstyle.xml'
    Boolean ignoreFailures = null
    Boolean showViolations = null
    String source = 'src'
    List<String> include = ['**/*.java']
    List<String> exclude = ['**/gen/**']
  }
  pmd {
    boolean enabled = true
    String toolVersion = '6.0.0'
    String ruleSetFile = 'code_quality_tools/pmd.xml'
    Boolean ignoreFailures = null
    String source = 'src'
    List<String> include = ['**/*.java']
    List<String> exclude = ['**/gen/**']
  }
  lint {
    boolean enabled = true
    Boolean textReport = true
    String textOutput = 'stdout'
    Boolean abortOnError = null
    Boolean warningsAsErrors = null
    Boolean checkAllWarnings = null
    String baselineFileName = null
    Boolean absolutePaths = null
    File lintConfig = null
    Boolean checkReleaseBuilds = false
    Boolean checkTestSources = null
    Boolean checkDependencies = null
  }
  ktlint {
    boolean enabled = true
    String toolVersion = '0.32.0'
    boolean experimental = false
  }
  cpd {
    boolean enabled = true
    String source = 'src'
    String language = 'java'
    Boolean ignoreFailures = null
    int minimumTokenCount = 50
  }
  kotlin {
    boolean allWarningsAsErrors = true
  }
}

Tools

Here I’ll give a bit more information about how each of the tools will be applied. If there’s a Gradle task that this plugin will generate it will also be hooked up into the check Gradle task. This means that when you execute check all of the rools will be running for you.

Checkstyle

It’ll apply the Checkstyle Plugin and generate the checkstyle task that will execute checkstyle. The configuration properties of codeQualityTools -> checkstyle mirror the properties from the plugin.

PMD

It’ll apply the PMD Plugin and generate the pmd task that will execute pmd. The configuration properties of codeQualityTools -> pmd mirror the properties from the plugin.

CPD

It’ll apply the CPD Plugin and generate the cpdCheck task that will execute cpd. The configuration properties of codeQualityTools -> cpd mirror the properties from the plugin.

Lint

This will only work when one of the Android Plugins (com.android.application, com.android.library, etc.) are applied. The configuration properties of codeQualityTools -> lint mirror the properties from the lintOptions.

Ktlint

It’ll use the specified ktlint version and then generate two tasks. ktlint which will run ktlint over your code and flag issues. ktlintFormat will reformat your code.

Note: There might be some configuration properties that are not mirrored in which case feel free to open a PR. Personally, I don’t have the need for all of them.

License

Copyright © 2016 Vanniktech - Niklas Baudy

Licensed under the Apache License, Version 2.0

评论

暂无评论