All Projects → yangziwen → diff-check

yangziwen / diff-check

Licence: LGPL-2.1 license
Incremental code analysis tools based on checkstyle, pmd and jacoco

Programming Languages

java
68154 projects - #9 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to diff-check

analysis-model
A library to read static analysis reports into a Java object model
Stars: ✭ 74 (+54.17%)
Mutual labels:  pmd, checkstyle
Gradle Quality Plugin
Gradle quality plugin for Java and Groovy
Stars: ✭ 97 (+102.08%)
Mutual labels:  pmd, checkstyle
Kotlin Android Starter
[Kotlin Android] Kotlin Android starter based MVP/Dagger2/RxJava2/Robolectric/Espresso/Mockito. It provides a generator to fast create a Kotlin Android project.
Stars: ✭ 589 (+1127.08%)
Mutual labels:  pmd, checkstyle
Tvflix
TvFlix android app using Dagger Hilt, Coroutines, Flow, KTX, Jetpack(Room, ViewModel, Paging3, Lifecycle) based on MVVM architecture purely written in Kotlin
Stars: ✭ 286 (+495.83%)
Mutual labels:  pmd, checkstyle
qulice
Quality Police for Java projects: aggregator of Checkstyle, PMD, and SpotBugs
Stars: ✭ 286 (+495.83%)
Mutual labels:  pmd, checkstyle
Gradle Static Analysis Plugin
Easy setup of static analysis tools for Android and Java projects.
Stars: ✭ 398 (+729.17%)
Mutual labels:  pmd, checkstyle
Quality Checks
Gradle plugin which includes Checkstyle, FindBugs, and PMD basic configuration.
Stars: ✭ 38 (-20.83%)
Mutual labels:  pmd, checkstyle
Debt-Manager
A personal app to store people that owe you money or you owe money to. "Mo Money Mo Problems" 🎵 - The Notorious B.I.G. 😎
Stars: ✭ 22 (-54.17%)
Mutual labels:  pmd, checkstyle
Qulice
Quality Police for Java projects
Stars: ✭ 250 (+420.83%)
Mutual labels:  pmd, checkstyle
Warnings Ng Plugin
Jenkins Warnings Plugin - Next Generation
Stars: ✭ 248 (+416.67%)
Mutual labels:  pmd, checkstyle
Okcheck
Incremental scan,integrate Lint、KtLint、UnitTest、Checkstyle、Findbugs、Pmd, powerful and easy to use
Stars: ✭ 285 (+493.75%)
Mutual labels:  pmd, checkstyle
advanced-spring-scaffold
This project provides an advanced baseline to help you kick start a Spring project.
Stars: ✭ 21 (-56.25%)
Mutual labels:  pmd, checkstyle
Gradle Code Quality Tools Plugin
Gradle plugin that generates ErrorProne, Findbugs, Checkstyle, PMD, CPD, Lint, Detekt & Ktlint Tasks for every subproject.
Stars: ✭ 282 (+487.5%)
Mutual labels:  pmd, checkstyle
Android Starter
[Android Architecture] Android starter based on MVP/Dagger2/RxJava2/Robolectric/Espresso/Mockito. It provides a generator to fast create a Android template project.
Stars: ✭ 522 (+987.5%)
Mutual labels:  pmd, checkstyle
static-code-analysis-plugin
A plugin to simplify Static Code Analysis on Gradle. Not restricted to, but specially useful, in Android projects, by making sure all analysis can access the SDK classes.
Stars: ✭ 36 (-25%)
Mutual labels:  pmd, checkstyle
Codeanalysis
Android静态代码分析
Stars: ✭ 31 (-35.42%)
Mutual labels:  pmd, checkstyle
Gnag
A Gradle plugin that helps facilitate GitHub PR checking and automatic commenting of violations.
Stars: ✭ 120 (+150%)
Mutual labels:  pmd, checkstyle
java-quality-checks
No description or website provided.
Stars: ✭ 33 (-31.25%)
Mutual labels:  pmd, checkstyle
ForgeModdingSkeleton
Skeletons for building Forge mods
Stars: ✭ 21 (-56.25%)
Mutual labels:  pmd, checkstyle
kotlin-plugin-generated
A Kotlin compiler plugin that annotates Kotlin-generated methods for improved coverage reports
Stars: ✭ 33 (-31.25%)
Mutual labels:  jacoco

diff-check

Build Status

Chinese Doc

Introduction

When using code analysis tools to scan a project, it will output all the problems in each file at once. This makes it difficult to perform an effective check on the codes under development before cleaning up all the existing problems.

In response to this pain point, I extended those tools including checkstyle, PMD and jacoco to perform scanning only on incremental changes of code lines.

Usage

Run the style and defect check when submitting a commit to your repository

  • You can run the following commands to install the check tools
# Download the install.sh
 curl https://raw.githubusercontent.com/yangziwen/diff-check/master/hooks/install.sh > install.sh

# Install the hook to a specified git repository
 sh install.sh --repo-path=${the_absolute_path_of_your_git_repository}

# Or install the hook globally
 sh install.sh --global=true
  • You can enable or disable the check in the following way
# Enable the check of checkstyle
 git config diff-check.checkstyle.enabled true
 
 # Disable the check of checkstyle
 git config diff-check.checkstyle.enabled false
 
 # Enable the check of PMD
 git config diff-check.pmd.enabled true
 
 # Disable the check of PMD
 git config diff-check.pmd.enabled false
  • You can set the check rules in the following way
 git config diff-check.checkstyle.config-file /custom_checks.xml
 
 git config diff-check.pmd.rulesets rulesets/java/ali-all.xml
  • You can set the exampt path in the following way
 git config diff-check.checkstyle.exclude-regexp .+-client/.*
 
 git config diff-check.pmd.exclude-regexp .+-client/.*
  • You can choose language in the following way (English is the default choice if the language you specified is not supported)
# Specify the message language of both checkstyle and pmd
git config diff-check.language en

# Only specify the message language of checkstyle
git config diff-check.checkstyle.language es

# Only specify the message language of pmd
git config diff-check.pmd.language zh

Run unit tests and get the code coverage report

  • Config the maven plugin
 <plugin>
     <groupId>io.github.yangziwen</groupId>
     <artifactId>diff-jacoco-maven-plugin</artifactId>
     <version>0.0.7</version>
     <configuration>
       <excludes>
         <!-- Specify the path to exclude -->
         <exclude>io/github/yangziwen/quickdao/example/entity/*</exclude>
       </excludes>
     </configuration>
     <executions>
         <execution>
             <id>pre-test</id>
             <goals>
                 <goal>prepare-agent</goal>
             </goals>
         </execution>
         <execution>
             <id>post-test</id>
             <phase>test</phase>
             <goals>
                 <goal>report</goal>
             </goals>
             <configuration>
                 <!-- config the path of the report -->
                 <outputDirectory>${project.reporting.outputDirectory}/jacoco-diff</outputDirectory>
             </configuration>
         </execution>
     </executions>
 </plugin>
  • Run the unit tests
 # Incremental code coverage scanning is achieved by specifying commit or branch for `jacoco.diff.oldrev` and `jacoco.diff.newrev`
 # If these two parameters are not specified, a full coverage scan will be performed
 mvn test -Djacoco.diff.oldrev=9ac9182 -Djacoco.diff.newrev=HEAD
 
 # Use `jacoco.diff.against` parameter,you can compare the difference between HEAD and any other commit or branch, and get the code coverage result between them. 
 mvn test -Djacoco.diff.against=origin/master

 # Use the `jacoco.author.name` or `jacoco.author.email` parameters to complete the coverage scanning according to the incremental code of the specified submitter
 mvn test -Djacoco.diff.against=origin/master -Djacoco.author.name=yangziwen
 
 You can run a single test class and get the report of it
 mvn clean test -Djacoco.diff.against=origin/master -DskipTests=false -Dtest=io.github.yangziwen.quickdao.example.repository.UserSpringJdbcRepositoryTest -DfailIfNoTests=false
  • Get the result
Full Code Coverage Incremental Code Coverage
全量覆盖率概览 增量覆盖率概览
全量覆盖率详情 增量覆盖率详情

Others

  • Besides sun_checks.xml and google_checks.xml provided by checkstyle by default, two other configurations custom_checks.xml and custom_full_checks.xml which compatible with the Alibaba code specification have been provided. You can use your favorite style configuration by specifying the absolute file path with -c option.
  • Add the lombok.config file to the root folder of your project, and add a line of lombok.addLombokGeneratedAnnotation = true in the file, then all the methods generated by lombok will be ignored in the code coverage scanning(https://projectlombok.org/features/configuration).
  • Scanning with a changed file that has not been submitted and also not been added to the staging area may cause the modified code line calculated being inconsistent with the code line of the actual scanned file in the workspace, so please submit all changes first.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].