commit
c0751fd7ca
40 changed files with 326 additions and 678 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
||||||
[submodule ".travis-support"]
|
|
||||||
path = .travis-support
|
|
||||||
url = https://github.com/kemitix/kemitix-travis-support.git
|
|
2
.mvn/wrapper/maven-wrapper.properties
vendored
2
.mvn/wrapper/maven-wrapper.properties
vendored
|
@ -1 +1 @@
|
||||||
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
|
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit b97def251b784ecc8de6d3cc30d2793ac0bd375e
|
|
12
.travis.yml
12
.travis.yml
|
@ -5,14 +5,4 @@ cache:
|
||||||
directories:
|
directories:
|
||||||
- "$HOME/.m2"
|
- "$HOME/.m2"
|
||||||
install: true
|
install: true
|
||||||
script: "./mvnw clean install"
|
script: "./mvnw --batch-mode --errors --update-snapshots clean install"
|
||||||
after_success:
|
|
||||||
- sh .travis-support/coveralls.sh
|
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
|
||||||
deploy:
|
|
||||||
provider: script
|
|
||||||
script: sh .travis-support/deploy.sh
|
|
||||||
on:
|
|
||||||
branch: master
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
|
|
10
CHANGELOG
10
CHANGELOG
|
@ -1,6 +1,16 @@
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
4.1.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* EmptyLineSeparator: disabled
|
||||||
|
* Upgrade `tiles-maven-plugin` to 2.11
|
||||||
|
* Upgrade `checkstyle` to 8.10
|
||||||
|
* Upgrade `sevntu-checkstyle` to 1.29.0
|
||||||
|
* Upgrade `secntu-checkstyle` to 1.27.0
|
||||||
|
* Upgrade `checkstyle` to 8.7 (properly now that it is supported by sevntu)
|
||||||
|
|
||||||
4.0.1
|
4.0.1
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
86
Jenkinsfile.groovy
Normal file
86
Jenkinsfile.groovy
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
final String mvn = "mvn --batch-mode --update-snapshots --errors"
|
||||||
|
final dependenciesSupportJDK=9
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
stages {
|
||||||
|
stage('master != SNAPSHOT') {
|
||||||
|
// checks that the pom version is not a snapshot when the current or target branch is master
|
||||||
|
when {
|
||||||
|
expression {
|
||||||
|
(env.GIT_BRANCH == 'master' || env.CHANGE_TARGET == 'master') &&
|
||||||
|
(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
error("Build failed because SNAPSHOT version")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build & Test') {
|
||||||
|
steps {
|
||||||
|
withMaven(maven: 'maven', jdk: 'JDK LTS') {
|
||||||
|
sh "${mvn} clean compile checkstyle:checkstyle pmd:pmd test"
|
||||||
|
//junit '**/target/surefire-reports/*.xml'
|
||||||
|
sh "${mvn} -pl builder jacoco:report com.gavinmogan:codacy-maven-plugin:coverage " +
|
||||||
|
"-DcoverageReportFile=target/site/jacoco/jacoco.xml " +
|
||||||
|
"-DprojectToken=`$JENKINS_HOME/codacy/token` " +
|
||||||
|
"-DapiToken=`$JENKINS_HOME/codacy/apitoken` " +
|
||||||
|
"-Dcommit=`git rev-parse HEAD`"
|
||||||
|
jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class'
|
||||||
|
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''
|
||||||
|
step([$class: 'hudson.plugins.checkstyle.CheckStylePublisher',
|
||||||
|
pattern: '**/target/checkstyle-result.xml',
|
||||||
|
healthy:'20',
|
||||||
|
unHealthy:'100'])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Verify & Install') {
|
||||||
|
steps {
|
||||||
|
withMaven(maven: 'maven', jdk: 'JDK LTS') {
|
||||||
|
sh "${mvn} -DskipTests install"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('SonarQube (github only)') {
|
||||||
|
when { expression { env.GIT_URL.startsWith('https://github.com') } }
|
||||||
|
steps {
|
||||||
|
withSonarQubeEnv('sonarqube') {
|
||||||
|
withMaven(maven: 'maven', jdk: 'JDK LTS') {
|
||||||
|
sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Archiving') {
|
||||||
|
when { expression { findFiles(glob: '**/target/*.jar').length > 0 } }
|
||||||
|
steps {
|
||||||
|
archiveArtifacts '**/target/*.jar'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Deploy (master on github)') {
|
||||||
|
when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://github.com')) } }
|
||||||
|
steps {
|
||||||
|
withMaven(maven: 'maven', jdk: 'JDK LTS') {
|
||||||
|
sh "${mvn} deploy --activate-profiles release -DskipTests=true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build Java 9') {
|
||||||
|
when { expression { dependenciesSupportJDK >= 9 } }
|
||||||
|
steps {
|
||||||
|
withMaven(maven: 'maven', jdk: 'JDK 9') {
|
||||||
|
sh "${mvn} clean verify -Djava.version=9"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build Java 10') {
|
||||||
|
when { expression { dependenciesSupportJDK >= 10 } }
|
||||||
|
steps {
|
||||||
|
withMaven(maven: 'maven', jdk: 'JDK 10') {
|
||||||
|
sh "${mvn} clean verify -Djava.version=10"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
62
README.md
62
README.md
|
@ -20,7 +20,7 @@ The simplest way to use the ruleset is with the maven-tile:
|
||||||
```xml
|
```xml
|
||||||
<project>
|
<project>
|
||||||
<properties>
|
<properties>
|
||||||
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
<tiles-maven-plugin.version>2.11</tiles-maven-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -101,7 +101,7 @@ Rule|Level|Source|Enabled|Suppressible
|
||||||
[EmptyCatchBlock](#emptycatchblock)|tweaks|checkstyle|Yes|
|
[EmptyCatchBlock](#emptycatchblock)|tweaks|checkstyle|Yes|
|
||||||
[EmptyForInitializerPad](#emptyforinitializerpad)|layout|checkstyle|Yes|
|
[EmptyForInitializerPad](#emptyforinitializerpad)|layout|checkstyle|Yes|
|
||||||
[EmptyForIteratorPad](#emptyforiteratorpad)|layout|checkstyle|Yes|
|
[EmptyForIteratorPad](#emptyforiteratorpad)|layout|checkstyle|Yes|
|
||||||
[EmptyLineSeparator](#emptylineseparator)|layout|checkstyle|Yes|
|
[EmptyLineSeparator](#emptylineseparator)|layout|checkstyle||
|
||||||
[EmptyPublicCtorInClass](#emptypublicctorinclass)|tweaks|sevntu|Yes|
|
[EmptyPublicCtorInClass](#emptypublicctorinclass)|tweaks|sevntu|Yes|
|
||||||
[EmptyStatement](#emptystatement)|layout|checkstyle|Yes|
|
[EmptyStatement](#emptystatement)|layout|checkstyle|Yes|
|
||||||
[EnumValueName](#enumvaluename)|naming|sevntu|Yes|
|
[EnumValueName](#enumvaluename)|naming|sevntu|Yes|
|
||||||
|
@ -768,59 +768,6 @@ Invalid:
|
||||||
````
|
````
|
||||||
for (Iterator i = list.getIterator(); i.hasNext() ; ) {}
|
for (Iterator i = list.getIterator(); i.hasNext() ; ) {}
|
||||||
````
|
````
|
||||||
#### [EmptyLineSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator)
|
|
||||||
|
|
||||||
Checks that there are blank lines between header, package, import blocks, field, constructors, methods, nested classes, static initialisers and instance initialisers.
|
|
||||||
|
|
||||||
Valid:
|
|
||||||
````
|
|
||||||
/**
|
|
||||||
* Licence header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.kemitix.foo;
|
|
||||||
|
|
||||||
import ...;
|
|
||||||
import ...;
|
|
||||||
|
|
||||||
class Foo {
|
|
||||||
|
|
||||||
private int a;
|
|
||||||
|
|
||||||
private int b;
|
|
||||||
|
|
||||||
Foo() {}
|
|
||||||
|
|
||||||
Foo(int a, int b) {}
|
|
||||||
|
|
||||||
int getA() {}
|
|
||||||
|
|
||||||
int getB() {}
|
|
||||||
|
|
||||||
class Bar {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
````
|
|
||||||
|
|
||||||
Invalid:
|
|
||||||
````
|
|
||||||
/**
|
|
||||||
* Licence header.
|
|
||||||
*/
|
|
||||||
package net.kemitix.foo;
|
|
||||||
import ...;
|
|
||||||
import ...;
|
|
||||||
class Foo {
|
|
||||||
private int a;
|
|
||||||
private int b;
|
|
||||||
Foo() {}
|
|
||||||
Foo(int a, int b) {}
|
|
||||||
int getA() {}
|
|
||||||
int getB() {}
|
|
||||||
class Bar {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
````
|
|
||||||
#### [EmptyStatement](http://checkstyle.sourceforge.net/config_coding.html#EmptyStatement)
|
#### [EmptyStatement](http://checkstyle.sourceforge.net/config_coding.html#EmptyStatement)
|
||||||
|
|
||||||
Checks for empty statements. An empty statement is a standalone semicolon (;).
|
Checks for empty statements. An empty statement is a standalone semicolon (;).
|
||||||
|
@ -2385,8 +2332,6 @@ if (condition) {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
````
|
````
|
||||||
|
|
||||||
Example: [MoveVariableInsideIf.java](https://github.com/kemitix/kemitix-checkstyle-ruleset/blob/master/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java)
|
|
||||||
#### [NameConventionForJunit4TestClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NameConventionForJunit4TestClassesCheck.html)
|
#### [NameConventionForJunit4TestClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NameConventionForJunit4TestClassesCheck.html)
|
||||||
|
|
||||||
Checks the names of JUnit test classes. Classes checked are those that have at least one method annotated with `Test` or `org.junit.Test`.
|
Checks the names of JUnit test classes. Classes checked are those that have at least one method annotated with `Test` or `org.junit.Test`.
|
||||||
|
@ -2643,6 +2588,9 @@ Ref: Clean Code, Robert C. Martin, J1: Avoid Long Import Lists by Using Wildcard
|
||||||
|
|
||||||
Ref: Clean Code, Robert C. Martin, J2: Don't Inherit Constants
|
Ref: Clean Code, Robert C. Martin, J2: Don't Inherit Constants
|
||||||
Recommends using a static import to access constants from another class over inheriting them.
|
Recommends using a static import to access constants from another class over inheriting them.
|
||||||
|
#### [EmptyLineSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator)
|
||||||
|
|
||||||
|
|
||||||
#### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable)
|
#### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable)
|
||||||
|
|
||||||
Doesn't recognise Lombok's `val` as being `final`.
|
Doesn't recognise Lombok's `val` as being `final`.
|
||||||
|
|
|
@ -7,23 +7,23 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.kemitix</groupId>
|
<groupId>net.kemitix</groupId>
|
||||||
<artifactId>kemitix-parent</artifactId>
|
<artifactId>kemitix-parent</artifactId>
|
||||||
<version>5.0.3</version>
|
<version>5.1.0</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.kemitix.checkstyle</groupId>
|
<groupId>net.kemitix.checkstyle</groupId>
|
||||||
<artifactId>builder</artifactId>
|
<artifactId>builder</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>4.0.1</version>
|
<version>4.1.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.install.skip>true</maven.install.skip>
|
<maven.install.skip>true</maven.install.skip>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
<tiles-maven-plugin.version>2.11</tiles-maven-plugin.version>
|
||||||
<kemitix-tiles.version>0.3.0</kemitix-tiles.version>
|
<kemitix-tiles.version>0.8.1</kemitix-tiles.version>
|
||||||
|
|
||||||
<checkstyle.version>8.6</checkstyle.version>
|
<checkstyle.version>8.10</checkstyle.version>
|
||||||
<sevntu.version>1.26.0</sevntu.version>
|
<sevntu.version>1.29.0</sevntu.version>
|
||||||
<lombok.version>1.16.20</lombok.version>
|
<lombok.version>1.16.20</lombok.version>
|
||||||
<spring-platform.version>Brussels-SR6</spring-platform.version>
|
<spring-platform.version>Brussels-SR6</spring-platform.version>
|
||||||
<spring-boot.version>1.5.9.RELEASE</spring-boot.version>
|
<spring-boot.version>1.5.9.RELEASE</spring-boot.version>
|
||||||
|
@ -31,6 +31,8 @@
|
||||||
<map-builder.version>1.0.0</map-builder.version>
|
<map-builder.version>1.0.0</map-builder.version>
|
||||||
<mockito.version>2.13.0</mockito.version>
|
<mockito.version>2.13.0</mockito.version>
|
||||||
<assertj.version>3.9.0</assertj.version>
|
<assertj.version>3.9.0</assertj.version>
|
||||||
|
<conditional.version>0.3.0</conditional.version>
|
||||||
|
<fast-classpath-scanner.version>2.18.1</fast-classpath-scanner.version>
|
||||||
|
|
||||||
<maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version>
|
<maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version>
|
||||||
<kemitix.checkstyle.ruleset.version>${project.version}</kemitix.checkstyle.ruleset.version>
|
<kemitix.checkstyle.ruleset.version>${project.version}</kemitix.checkstyle.ruleset.version>
|
||||||
|
@ -58,6 +60,16 @@
|
||||||
<version>${lombok.version}</version>
|
<version>${lombok.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kemitix</groupId>
|
||||||
|
<artifactId>conditional</artifactId>
|
||||||
|
<version>${conditional.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.lukehutch</groupId>
|
||||||
|
<artifactId>fast-classpath-scanner</artifactId>
|
||||||
|
<version>${fast-classpath-scanner.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
|
@ -130,14 +142,14 @@
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<tiles>
|
<tiles>
|
||||||
<tile>net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:maven-plugins:${kemitix-tiles.version}</tile>
|
||||||
<tile>net.kemitix.tiles:enforcer-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:enforcer:${kemitix-tiles.version}</tile>
|
||||||
<tile>net.kemitix.tiles:compiler-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:compiler:${kemitix-tiles.version}</tile>
|
||||||
<tile>net.kemitix.tiles:huntbugs-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:huntbugs:${kemitix-tiles.version}</tile>
|
||||||
<tile>net.kemitix.tiles:pmd-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:pmd:${kemitix-tiles.version}</tile>
|
||||||
<tile>net.kemitix.tiles:testing-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:testing:${kemitix-tiles.version}</tile>
|
||||||
<tile>net.kemitix.tiles:coverage-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:coverage:${kemitix-tiles.version}</tile>
|
||||||
<tile>net.kemitix.tiles:pitest-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:pitest:${kemitix-tiles.version}</tile>
|
||||||
</tiles>
|
</tiles>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -21,15 +21,12 @@
|
||||||
|
|
||||||
package net.kemitix.checkstyle.ruleset.builder;
|
package net.kemitix.checkstyle.ruleset.builder;
|
||||||
|
|
||||||
import com.google.common.reflect.ClassPath;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@ -41,18 +38,6 @@ import java.util.stream.Stream;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class BuilderConfiguration {
|
public class BuilderConfiguration {
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the ClassPath used to scan packages.
|
|
||||||
*
|
|
||||||
* @return the ClassPath
|
|
||||||
*
|
|
||||||
* @throws IOException if there is an error
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public ClassPath classPath() throws IOException {
|
|
||||||
return ClassPath.from(getClass().getClassLoader());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Map of rules for each RuleSource.
|
* A Map of rules for each RuleSource.
|
||||||
*
|
*
|
||||||
|
@ -63,24 +48,11 @@ public class BuilderConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
public Map<RuleSource, List<String>> checkClasses(final PackageScanner packageScanner) {
|
public Map<RuleSource, List<String>> checkClasses(final PackageScanner packageScanner) {
|
||||||
return Stream.of(RuleSource.values())
|
return Stream.of(RuleSource.values())
|
||||||
.map(toRuleSourceEntry(packageScanner))
|
.map(source -> entry(source, packageScanner.apply(source)))
|
||||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Function<RuleSource, AbstractMap.SimpleEntry<RuleSource, List<String>>> toRuleSourceEntry(
|
private static <K, V> AbstractMap.SimpleEntry<K, V> entry(final K key, final V value) {
|
||||||
final PackageScanner packageScanner
|
return new AbstractMap.SimpleEntry<>(key, value);
|
||||||
) {
|
|
||||||
return source -> new AbstractMap.SimpleEntry<>(
|
|
||||||
source,
|
|
||||||
classesInSource(source, packageScanner)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<String> classesInSource(
|
|
||||||
final RuleSource source,
|
|
||||||
final PackageScanner packageScanner
|
|
||||||
) {
|
|
||||||
return packageScanner.apply(source)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,21 +21,22 @@
|
||||||
|
|
||||||
package net.kemitix.checkstyle.ruleset.builder;
|
package net.kemitix.checkstyle.ruleset.builder;
|
||||||
|
|
||||||
import com.speedment.common.mapstream.MapStream;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import lombok.val;
|
|
||||||
import org.springframework.boot.CommandLineRunner;
|
import org.springframework.boot.CommandLineRunner;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.nio.file.Path;
|
||||||
import java.util.Map;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the Checkstyle XML files.
|
* Writes the Checkstyle XML files.
|
||||||
*
|
*
|
||||||
|
@ -46,8 +47,6 @@ import java.util.stream.Stream;
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
class CheckstyleWriter implements CommandLineRunner {
|
class CheckstyleWriter implements CommandLineRunner {
|
||||||
|
|
||||||
private static final String NEWLINE = System.getProperty("line.separator");
|
|
||||||
|
|
||||||
private final OutputProperties outputProperties;
|
private final OutputProperties outputProperties;
|
||||||
|
|
||||||
private final TemplateProperties templateProperties;
|
private final TemplateProperties templateProperties;
|
||||||
|
@ -56,62 +55,79 @@ class CheckstyleWriter implements CommandLineRunner {
|
||||||
|
|
||||||
private final RuleClassLocator ruleClassLocator;
|
private final RuleClassLocator ruleClassLocator;
|
||||||
|
|
||||||
|
private static Predicate<RuleLevel> excludeUnspecifiedRuleLevel() {
|
||||||
|
return level -> !level.equals(RuleLevel.UNSPECIFIED);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void writeRuleset(
|
||||||
|
final Path filePath,
|
||||||
|
final String content
|
||||||
|
) throws IOException {
|
||||||
|
Files.write(filePath, asList(content.split(System.lineSeparator())), StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String ruleset(
|
||||||
|
final String checkerRules,
|
||||||
|
final String treeWalkerRules,
|
||||||
|
final String template
|
||||||
|
) {
|
||||||
|
return String.format(template, checkerRules, treeWalkerRules);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean fileExists(final File file) {
|
||||||
|
return file.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void writeCheckstyleFileWithException(
|
||||||
|
final Path outputPath,
|
||||||
|
final String checkerRules,
|
||||||
|
final String treeWalkerRules,
|
||||||
|
final Path template
|
||||||
|
) throws IOException {
|
||||||
|
if (fileExists(template.toFile())) {
|
||||||
|
log.info("Writing ruleset: {}", outputPath);
|
||||||
|
final String xmlTemplate = new String(Files.readAllBytes(template), StandardCharsets.UTF_8);
|
||||||
|
writeRuleset(outputPath, ruleset(checkerRules, treeWalkerRules, xmlTemplate));
|
||||||
|
} else {
|
||||||
|
throw new TemplateNotFoundException(template);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(final String... args) {
|
public void run(final String... args) {
|
||||||
Stream.of(RuleLevel.values())
|
Stream.of(RuleLevel.values())
|
||||||
.filter(level -> !level.equals(RuleLevel.UNSPECIFIED))
|
.filter(excludeUnspecifiedRuleLevel())
|
||||||
.forEach(this::writeCheckstyleFile);
|
.forEach(this::writeCheckstyleFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeCheckstyleFile(final RuleLevel ruleLevel) {
|
private void writeCheckstyleFile(final RuleLevel ruleLevel) {
|
||||||
val xmlFile = outputProperties.getDirectory()
|
final Path outputPath = outputPath(ruleLevel);
|
||||||
.resolve(outputProperties.getRulesetFiles()
|
final String checkerRules = enabledRules(ruleLevel, RuleParent.CHECKER);
|
||||||
.get(ruleLevel));
|
final String treeWalkerRules = enabledRules(ruleLevel, RuleParent.TREEWALKER);
|
||||||
val checkerRules = rulesProperties.getRules()
|
final Path template = templateProperties.getCheckstyleXml();
|
||||||
.stream()
|
|
||||||
.filter(Rule::isEnabled)
|
|
||||||
.filter(rule -> RuleParent.CHECKER.equals(rule.getParent()))
|
|
||||||
.filter(rule -> ruleLevel.compareTo(rule.getLevel()) >= 0)
|
|
||||||
.map(this::formatRuleAsModule)
|
|
||||||
.collect(Collectors.joining(NEWLINE));
|
|
||||||
val treeWalkerRules = rulesProperties.getRules()
|
|
||||||
.stream()
|
|
||||||
.filter(Rule::isEnabled)
|
|
||||||
.filter(rule -> RuleParent.TREEWALKER.equals(rule.getParent()))
|
|
||||||
.filter(rule -> ruleLevel.compareTo(rule.getLevel()) >= 0)
|
|
||||||
.map(this::formatRuleAsModule)
|
|
||||||
.collect(Collectors.joining(NEWLINE));
|
|
||||||
try {
|
try {
|
||||||
val checkstyleXmlTemplate = templateProperties.getCheckstyleXml();
|
writeCheckstyleFileWithException(outputPath, checkerRules, treeWalkerRules, template);
|
||||||
if (checkstyleXmlTemplate.toFile()
|
|
||||||
.exists()) {
|
|
||||||
val bytes = Files.readAllBytes(checkstyleXmlTemplate);
|
|
||||||
val template = new String(bytes, StandardCharsets.UTF_8);
|
|
||||||
val output = Arrays.asList(String.format(template, checkerRules, treeWalkerRules)
|
|
||||||
.split(NEWLINE));
|
|
||||||
log.info("Writing xmlFile: {}", xmlFile);
|
|
||||||
Files.write(xmlFile, output, StandardCharsets.UTF_8);
|
|
||||||
} else {
|
|
||||||
throw new TemplateNotFoundException(checkstyleXmlTemplate);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new CheckstyleWriterException(e);
|
throw new CheckstyleWriterException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatRuleAsModule(final Rule rule) {
|
private Path outputPath(final RuleLevel ruleLevel) {
|
||||||
if (rule.getProperties()
|
return outputProperties.getDirectory()
|
||||||
.isEmpty()) {
|
.resolve(outputProperties.getRulesetFiles()
|
||||||
return String.format("<module name=\"%s\"/>", ruleClassLocator.apply(rule));
|
.get(ruleLevel));
|
||||||
}
|
|
||||||
return String.format("<module name=\"%s\">%n %s%n</module>", ruleClassLocator.apply(rule),
|
|
||||||
formatProperties(rule.getProperties())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatProperties(final Map<String, String> properties) {
|
private String enabledRules(
|
||||||
return MapStream.of(properties)
|
final RuleLevel ruleLevel,
|
||||||
.map((k, v) -> String.format("<property name=\"%s\" value=\"%s\"/>", k, v))
|
final RuleParent ruleParent
|
||||||
.collect(Collectors.joining(NEWLINE));
|
) {
|
||||||
|
return rulesProperties.getRules()
|
||||||
|
.stream()
|
||||||
|
.filter(Rule::isEnabled)
|
||||||
|
.filter(Rule.hasParent(ruleParent))
|
||||||
|
.filter(Rule.isIncludedInLevel(ruleLevel))
|
||||||
|
.map(rule -> Rule.asModule(ruleClassLocator.apply(rule), rule))
|
||||||
|
.collect(Collectors.joining(System.lineSeparator()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,11 @@
|
||||||
|
|
||||||
package net.kemitix.checkstyle.ruleset.builder;
|
package net.kemitix.checkstyle.ruleset.builder;
|
||||||
|
|
||||||
import com.google.common.reflect.ClassPath;
|
import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of {@link PackageScanner}.
|
* Default implementation of {@link PackageScanner}.
|
||||||
|
@ -33,15 +33,16 @@ import java.util.stream.Stream;
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net).
|
* @author Paul Campbell (pcampbell@kemitix.net).
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class DefaultPackageScanner implements PackageScanner {
|
public class DefaultPackageScanner implements PackageScanner {
|
||||||
|
|
||||||
private final ClassPath classPath;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Stream<String> apply(final RuleSource ruleSource) {
|
public final List<String> apply(final RuleSource ruleSource) {
|
||||||
return classPath.getTopLevelClassesRecursive(ruleSource.getBasePackage())
|
final String basePackage = ruleSource.getBasePackage();
|
||||||
.stream()
|
return new FastClasspathScanner(basePackage)
|
||||||
.map(ClassPath.ClassInfo::getName);
|
.scan()
|
||||||
|
.getNamesOfAllStandardClasses()
|
||||||
|
.stream()
|
||||||
|
.filter(packageName -> packageName.startsWith(basePackage))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
|
|
||||||
package net.kemitix.checkstyle.ruleset.builder;
|
package net.kemitix.checkstyle.ruleset.builder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scans a package for all classes.
|
* Scans a package for all classes.
|
||||||
*
|
*
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net).
|
* @author Paul Campbell (pcampbell@kemitix.net).
|
||||||
*/
|
*/
|
||||||
interface PackageScanner extends Function<RuleSource, Stream<String>> {
|
interface PackageScanner extends Function<RuleSource, List<String>> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,17 @@
|
||||||
|
|
||||||
package net.kemitix.checkstyle.ruleset.builder;
|
package net.kemitix.checkstyle.ruleset.builder;
|
||||||
|
|
||||||
|
import com.speedment.common.mapstream.MapStream;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import net.kemitix.conditional.Value;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single Checkstyle Check.
|
* A single Checkstyle Check.
|
||||||
|
@ -40,6 +44,10 @@ public class Rule {
|
||||||
|
|
||||||
private static final Locale LOCALE = Locale.ENGLISH;
|
private static final Locale LOCALE = Locale.ENGLISH;
|
||||||
|
|
||||||
|
private static final String MODULE_NO_PROPERTIES = "<module name=\"%s\"/>";
|
||||||
|
|
||||||
|
private static final String MODULE_WITH_PROPERTIES = "<module name=\"%s\">%n %s%n</module>";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration properties.
|
* Configuration properties.
|
||||||
*/
|
*/
|
||||||
|
@ -100,6 +108,69 @@ public class Rule {
|
||||||
.compareTo(right.getLowerCaseRuleName());
|
.compareTo(right.getLowerCaseRuleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Predicate to check that the Rule has the given RuleParent.
|
||||||
|
*
|
||||||
|
* @param ruleParent the RuleParent to match
|
||||||
|
*
|
||||||
|
* @return a Predicate to check a Rule
|
||||||
|
*/
|
||||||
|
static Predicate<Rule> hasParent(final RuleParent ruleParent) {
|
||||||
|
return rule -> ruleParent.equals(rule.getParent());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Predicate to check that the Rule is included in the given RuleLevel.
|
||||||
|
*
|
||||||
|
* @param ruleLevel the RuleLevel to match
|
||||||
|
*
|
||||||
|
* @return a Predicate to check a Rule
|
||||||
|
*/
|
||||||
|
static Predicate<Rule> isIncludedInLevel(final RuleLevel ruleLevel) {
|
||||||
|
return rule -> ruleLevel.compareTo(rule.getLevel()) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatProperties(final Map<String, String> properties) {
|
||||||
|
return MapStream.of(properties)
|
||||||
|
.map((k, v) -> String.format("<property name=\"%s\" value=\"%s\"/>", k, v))
|
||||||
|
.collect(Collectors.joining(System.lineSeparator()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean hasProperties(final Rule rule) {
|
||||||
|
return !rule.getProperties().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the Rule as an XML module fragment.
|
||||||
|
*
|
||||||
|
* @param rule the Rule to format
|
||||||
|
* @param ruleClassname the classname for the Rule
|
||||||
|
*
|
||||||
|
* @return an XML {@code <module/>} fragment
|
||||||
|
*/
|
||||||
|
static String asModule(
|
||||||
|
final String ruleClassname,
|
||||||
|
final Rule rule
|
||||||
|
) {
|
||||||
|
return Value.<String>where(hasProperties(rule))
|
||||||
|
.then(() -> moduleWithParameters(rule, ruleClassname))
|
||||||
|
.otherwise(() -> moduleNoParameters(ruleClassname));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String moduleNoParameters(
|
||||||
|
final String ruleClassname
|
||||||
|
) {
|
||||||
|
return String.format(MODULE_NO_PROPERTIES, ruleClassname);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String moduleWithParameters(
|
||||||
|
final Rule rule,
|
||||||
|
final String ruleClassname
|
||||||
|
) {
|
||||||
|
return String.format(MODULE_WITH_PROPERTIES, ruleClassname, formatProperties(rule.getProperties()));
|
||||||
|
}
|
||||||
|
|
||||||
private String getLowerCaseRuleName() {
|
private String getLowerCaseRuleName() {
|
||||||
return getName().toLowerCase(LOCALE);
|
return getName().toLowerCase(LOCALE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ The simplest way to use the ruleset is with the maven-tile:
|
||||||
```xml
|
```xml
|
||||||
<project>
|
<project>
|
||||||
<properties>
|
<properties>
|
||||||
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
<tiles-maven-plugin.version>2.11</tiles-maven-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
@ -241,9 +241,10 @@ rules:
|
||||||
name: EmptyLineSeparator
|
name: EmptyLineSeparator
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
level: LAYOUT
|
level: LAYOUT
|
||||||
enabled: true
|
enabled: false
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator
|
uri: http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator
|
||||||
|
reason:
|
||||||
-
|
-
|
||||||
name: EmptyStatement
|
name: EmptyStatement
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
|
@ -296,6 +297,8 @@ rules:
|
||||||
enabled: true
|
enabled: true
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_sizes.html#FileLength
|
uri: http://checkstyle.sourceforge.net/config_sizes.html#FileLength
|
||||||
|
properties:
|
||||||
|
max: 500
|
||||||
-
|
-
|
||||||
name: FileTabCharacter
|
name: FileTabCharacter
|
||||||
parent: CHECKER
|
parent: CHECKER
|
||||||
|
@ -463,9 +466,9 @@ rules:
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_metrics.html#JavaNCSS
|
uri: http://checkstyle.sourceforge.net/config_metrics.html#JavaNCSS
|
||||||
properties:
|
properties:
|
||||||
classMaximum: 1200
|
classMaximum: 250
|
||||||
fileMaximum: 1600
|
fileMaximum: 250
|
||||||
methodMaximum: 40
|
methodMaximum: 12
|
||||||
-
|
-
|
||||||
name: LeftCurly
|
name: LeftCurly
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
|
@ -518,7 +521,7 @@ rules:
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_sizes.html#MethodCount
|
uri: http://checkstyle.sourceforge.net/config_sizes.html#MethodCount
|
||||||
properties:
|
properties:
|
||||||
maxTotal: 30
|
maxTotal: 10
|
||||||
-
|
-
|
||||||
name: MethodLength
|
name: MethodLength
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
|
@ -527,7 +530,7 @@ rules:
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_sizes.html#MethodLength
|
uri: http://checkstyle.sourceforge.net/config_sizes.html#MethodLength
|
||||||
properties:
|
properties:
|
||||||
max: 40
|
max: 30
|
||||||
-
|
-
|
||||||
name: MethodName
|
name: MethodName
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
|
|
|
@ -18,5 +18,3 @@ if (condition) {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
````
|
````
|
||||||
|
|
||||||
Example: [MoveVariableInsideIf.java](https://github.com/kemitix/kemitix-checkstyle-ruleset/blob/master/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java)
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static java.util.Collections.singletonList;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
@ -20,28 +21,20 @@ import static org.mockito.Mockito.mock;
|
||||||
*/
|
*/
|
||||||
public class BuilderConfigurationTest {
|
public class BuilderConfigurationTest {
|
||||||
|
|
||||||
@Test
|
|
||||||
public void canGetClassPath() throws IOException {
|
|
||||||
//when
|
|
||||||
final ClassPath classPath = new BuilderConfiguration().classPath();
|
|
||||||
//then
|
|
||||||
assertThat(classPath).isNotNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canGetCheckClasses() {
|
public void canGetCheckClasses() {
|
||||||
//given
|
//given
|
||||||
final PackageScanner packageScanner = mock(PackageScanner.class);
|
final PackageScanner packageScanner = mock(PackageScanner.class);
|
||||||
final String checkstyleClass = "checkstyle class";
|
final String checkstyleClass = "checkstyle class";
|
||||||
given(packageScanner.apply(RuleSource.CHECKSTYLE)).willReturn(Stream.of(checkstyleClass));
|
given(packageScanner.apply(RuleSource.CHECKSTYLE)).willReturn(singletonList(checkstyleClass));
|
||||||
final String sevntuClass = "sevntu class";
|
final String sevntuClass = "sevntu class";
|
||||||
given(packageScanner.apply(RuleSource.SEVNTU)).willReturn(Stream.of(sevntuClass));
|
given(packageScanner.apply(RuleSource.SEVNTU)).willReturn(singletonList(sevntuClass));
|
||||||
//when
|
//when
|
||||||
final Map<RuleSource, List<String>> checkClasses = new BuilderConfiguration().checkClasses(packageScanner);
|
final Map<RuleSource, List<String>> checkClasses = new BuilderConfiguration().checkClasses(packageScanner);
|
||||||
//then
|
//then
|
||||||
assertThat(checkClasses).containsOnlyKeys(RuleSource.values());
|
assertThat(checkClasses).containsOnlyKeys(RuleSource.values());
|
||||||
assertThat(checkClasses)
|
assertThat(checkClasses)
|
||||||
.containsEntry(RuleSource.CHECKSTYLE, Collections.singletonList(checkstyleClass))
|
.containsEntry(RuleSource.CHECKSTYLE, singletonList(checkstyleClass))
|
||||||
.containsEntry(RuleSource.SEVNTU, Collections.singletonList(sevntuClass));
|
.containsEntry(RuleSource.SEVNTU, singletonList(sevntuClass));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package net.kemitix.checkstyle.ruleset.builder;
|
package net.kemitix.checkstyle.ruleset.builder;
|
||||||
|
|
||||||
import com.google.common.reflect.ClassPath;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -16,27 +14,21 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*/
|
*/
|
||||||
public class DefaultPackageScannerTest {
|
public class DefaultPackageScannerTest {
|
||||||
|
|
||||||
private PackageScanner scanner;
|
private PackageScanner scanner = new DefaultPackageScanner();
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
final ClassPath classPath = ClassPath.from(getClass().getClassLoader());
|
|
||||||
scanner = new DefaultPackageScanner(classPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canScanCheckstylePackage() throws IOException {
|
public void canScanCheckstylePackage() {
|
||||||
//when
|
//when
|
||||||
final Stream<String> result = scanner.apply(RuleSource.CHECKSTYLE);
|
final List<String> result = scanner.apply(RuleSource.CHECKSTYLE);
|
||||||
//then
|
//then
|
||||||
assertThat(result).allMatch(cn -> cn.startsWith(RuleSource.CHECKSTYLE.getBasePackage()))
|
assertThat(result).allMatch(cn -> cn.startsWith(RuleSource.CHECKSTYLE.getBasePackage()))
|
||||||
.contains("com.puppycrawl.tools.checkstyle.checks.sizes.FileLengthCheck");
|
.contains("com.puppycrawl.tools.checkstyle.checks.sizes.FileLengthCheck");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canScanSevntuPackage() throws IOException {
|
public void canScanSevntuPackage() {
|
||||||
//when
|
//when
|
||||||
final Stream<String> result = scanner.apply(RuleSource.SEVNTU);
|
final List<String> result = scanner.apply(RuleSource.SEVNTU);
|
||||||
//then
|
//then
|
||||||
assertThat(result).allMatch(cn -> cn.startsWith(RuleSource.SEVNTU.getBasePackage()))
|
assertThat(result).allMatch(cn -> cn.startsWith(RuleSource.SEVNTU.getBasePackage()))
|
||||||
.contains("com.github.sevntu.checkstyle.checks.design.NestedSwitchCheck");
|
.contains("com.github.sevntu.checkstyle.checks.design.NestedSwitchCheck");
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
test:
|
|
||||||
override:
|
|
||||||
- ./mvnw clean install
|
|
5
pom.xml
5
pom.xml
|
@ -5,8 +5,8 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>net.kemitix.checkstyle</groupId>
|
<groupId>net.kemitix.checkstyle</groupId>
|
||||||
<artifactId>root</artifactId>
|
<artifactId>kemitix-checkstyle-ruleset</artifactId>
|
||||||
<version>4.0.1</version>
|
<version>4.1.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -16,7 +16,6 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module>builder</module>
|
<module>builder</module>
|
||||||
<module>ruleset</module>
|
<module>ruleset</module>
|
||||||
<module>regressions</module>
|
|
||||||
<module>tile</module>
|
<module>tile</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>net.kemitix</groupId>
|
|
||||||
<artifactId>kemitix-parent</artifactId>
|
|
||||||
<version>5.0.3</version>
|
|
||||||
<relativePath/>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<groupId>net.kemitix.checkstyle</groupId>
|
|
||||||
<artifactId>regressions</artifactId>
|
|
||||||
<version>4.0.1</version>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.install.skip>true</maven.install.skip>
|
|
||||||
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
|
||||||
<kemitix-tiles.version>0.2.0</kemitix-tiles.version>
|
|
||||||
|
|
||||||
<checkstyle.version>8.6</checkstyle.version>
|
|
||||||
<sevntu.version>1.26.0</sevntu.version>
|
|
||||||
<maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version>
|
|
||||||
<kemitix.checkstyle.ruleset.version>${project.version}</kemitix.checkstyle.ruleset.version>
|
|
||||||
<!--<kemitix.checkstyle.ruleset.level>5-complexity</kemitix.checkstyle.ruleset.level>-->
|
|
||||||
<!-- use the disabled ruleset for normal builds. comment out the following line to check that conditions are caught -->
|
|
||||||
<kemitix.checkstyle.ruleset.level>0-disabled</kemitix.checkstyle.ruleset.level>
|
|
||||||
<kemitix.checkstyle.ruleset.location>net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml</kemitix.checkstyle.ruleset.location>
|
|
||||||
<digraph-dependency.basePackage>net.kemitix.checkstyle.regressions</digraph-dependency.basePackage>
|
|
||||||
<pitest.skip>true</pitest.skip>
|
|
||||||
<immutables-value.version>2.5.6</immutables-value.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.immutables</groupId>
|
|
||||||
<artifactId>value</artifactId>
|
|
||||||
<version>${immutables-value.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>io.repaint.maven</groupId>
|
|
||||||
<artifactId>tiles-maven-plugin</artifactId>
|
|
||||||
<version>${tiles-maven-plugin.version}</version>
|
|
||||||
<extensions>true</extensions>
|
|
||||||
<configuration>
|
|
||||||
<tiles>
|
|
||||||
<tile>net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version}</tile>
|
|
||||||
<tile>net.kemitix.tiles:compiler-tile:${kemitix-tiles.version}</tile>
|
|
||||||
</tiles>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
|
||||||
<version>${maven-checkstyle-plugin.version}</version>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.puppycrawl.tools</groupId>
|
|
||||||
<artifactId>checkstyle</artifactId>
|
|
||||||
<version>${checkstyle.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.sevntu-checkstyle</groupId>
|
|
||||||
<artifactId>sevntu-checkstyle-maven-plugin</artifactId>
|
|
||||||
<version>${sevntu.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kemitix.checkstyle</groupId>
|
|
||||||
<artifactId>ruleset</artifactId>
|
|
||||||
<version>${kemitix.checkstyle.ruleset.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<configuration>
|
|
||||||
<configLocation>${kemitix.checkstyle.ruleset.location}</configLocation>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>check</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,40 +0,0 @@
|
||||||
/**
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Paul Campbell
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
||||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies
|
|
||||||
* or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.kemitix.checkstyle.regressions;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Regression test for {@code AvoidDefaultSerializableInInnerClasses}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
public class AvoidDefaultSerializableInInnerClasses {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inner class should not use default implementations of {@code readObject()} and {@code writeObject()}.
|
|
||||||
*/
|
|
||||||
public class InnerClass implements Serializable {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
/**
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Paul Campbell
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
||||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies
|
|
||||||
* or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.kemitix.checkstyle.regressions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample class with no checkstyle issues.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
class Basic {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
/**
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Paul Campbell
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
||||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies
|
|
||||||
* or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.kemitix.checkstyle.regressions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Regression demo for {@code EmptyPublicCtorInClassCheck}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
public class EmptyPublicCtorInClass {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Useless empty public constructors.
|
|
||||||
*/
|
|
||||||
EmptyPublicCtorInClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
/**
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Paul Campbell
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
||||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies
|
|
||||||
* or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.kemitix.checkstyle.regressions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Regression demo for {@code ExplicitInitializationCheck}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net).
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({"hideutilityclassconstructor", "PMD.UnusedPrivateField"})
|
|
||||||
class ExplicitInitialization {
|
|
||||||
|
|
||||||
private boolean validBoolean = false;
|
|
||||||
|
|
||||||
private int validInt = 0;
|
|
||||||
|
|
||||||
private String validString = "";
|
|
||||||
|
|
||||||
private Object validObject = new Object();
|
|
||||||
|
|
||||||
private Boolean invalidBoolean = null;
|
|
||||||
|
|
||||||
private Integer invalidInteger = null;
|
|
||||||
|
|
||||||
private String invalidString = null;
|
|
||||||
|
|
||||||
private Object invalidObject = null;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
/**
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Paul Campbell
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
||||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies
|
|
||||||
* or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.kemitix.checkstyle.regressions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Regression test for {@code FinalizeImplementationCheck}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell pcampbell@kemitix.net
|
|
||||||
*/
|
|
||||||
class FinalizeImplementation {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Negates effect of superclass finalize.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("PMD.EmptyFinalizer")
|
|
||||||
protected void finalize() {
|
|
||||||
// doesn't call super.finalize()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
/**
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Paul Campbell
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
||||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies
|
|
||||||
* or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.kemitix.checkstyle.regressions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Regression demo for {@code MoveVariableInsideIfCheck}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
class MoveVariableInsideIf {
|
|
||||||
|
|
||||||
private String input = "1";
|
|
||||||
|
|
||||||
private boolean condition;
|
|
||||||
|
|
||||||
private String method(final String variable) {
|
|
||||||
return "value: " + variable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fails if not suppressed.
|
|
||||||
*
|
|
||||||
* @return value
|
|
||||||
*/
|
|
||||||
protected String invalid() {
|
|
||||||
String variable = input.substring(1);
|
|
||||||
if (condition) {
|
|
||||||
return method(variable);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rewrite {@link #invalid()} as this to pass.
|
|
||||||
*
|
|
||||||
* @return value
|
|
||||||
*/
|
|
||||||
protected String valid() {
|
|
||||||
if (condition) {
|
|
||||||
String variable = input.substring(1);
|
|
||||||
return method(variable);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/**
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Paul Campbell
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
||||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies
|
|
||||||
* or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.kemitix.checkstyle.regressions;
|
|
||||||
|
|
||||||
import org.immutables.value.Value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Regression subject for org.immutables.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
@Value.Immutable
|
|
||||||
public interface Values {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the ID.
|
|
||||||
*
|
|
||||||
* @return the id
|
|
||||||
*/
|
|
||||||
@Value.Parameter
|
|
||||||
long getId();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
/**
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Paul Campbell
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
||||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies
|
|
||||||
* or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.kemitix.checkstyle.regressions;
|
|
|
@ -7,13 +7,13 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.kemitix</groupId>
|
<groupId>net.kemitix</groupId>
|
||||||
<artifactId>kemitix-parent</artifactId>
|
<artifactId>kemitix-parent</artifactId>
|
||||||
<version>5.0.3</version>
|
<version>5.1.0</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.kemitix.checkstyle</groupId>
|
<groupId>net.kemitix.checkstyle</groupId>
|
||||||
<artifactId>ruleset</artifactId>
|
<artifactId>ruleset</artifactId>
|
||||||
<version>4.0.1</version>
|
<version>4.1.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Kemitix Checkstyle Ruleset</name>
|
<name>Kemitix Checkstyle Ruleset</name>
|
||||||
|
@ -21,8 +21,8 @@
|
||||||
<url>https://github.com/kemitix/kemitix-checkstyle-ruleset</url>
|
<url>https://github.com/kemitix/kemitix-checkstyle-ruleset</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
<tiles-maven-plugin.version>2.11</tiles-maven-plugin.version>
|
||||||
<kemitix-tiles.version>0.2.0</kemitix-tiles.version>
|
<kemitix-tiles.version>0.8.1</kemitix-tiles.version>
|
||||||
<maven-resources-plugin.version>3.0.2</maven-resources-plugin.version>
|
<maven-resources-plugin.version>3.0.2</maven-resources-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -57,9 +57,8 @@
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<tiles>
|
<tiles>
|
||||||
<tile>net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:maven-plugins:${kemitix-tiles.version}</tile>
|
||||||
<tile>net.kemitix.tiles:enforcer-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:enforcer:${kemitix-tiles.version}</tile>
|
||||||
<tile>net.kemitix.tiles:release-tile:${kemitix-tiles.version}</tile>
|
|
||||||
</tiles>
|
</tiles>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck"/>
|
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck"/>
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck"/>
|
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.naming.InterfaceTypeParameterNameCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.naming.InterfaceTypeParameterNameCheck"/>
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck"/>
|
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.FallThroughCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.FallThroughCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck"/>
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
</module>
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck"/>
|
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck">
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
<property name="fileNamePattern" value="(.sync-conflict-| conflicted copy )"/>
|
<property name="fileNamePattern" value="(.sync-conflict-| conflicted copy )"/>
|
||||||
<property name="match" value="true"/>
|
<property name="match" value="true"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.FileLengthCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.FileLengthCheck">
|
||||||
|
<property name="max" value="500"/>
|
||||||
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck">
|
||||||
<property name="fileExtensions" value="java"/>
|
<property name="fileExtensions" value="java"/>
|
||||||
|
@ -60,7 +62,6 @@
|
||||||
</module>
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck"/>
|
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck"/>
|
||||||
|
@ -97,9 +98,9 @@
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck">
|
||||||
<property name="classMaximum" value="1200"/>
|
<property name="classMaximum" value="250"/>
|
||||||
<property name="fileMaximum" value="1600"/>
|
<property name="fileMaximum" value="250"/>
|
||||||
<property name="methodMaximum" value="40"/>
|
<property name="methodMaximum" value="12"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck">
|
||||||
|
@ -110,10 +111,10 @@
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.MethodCountCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.MethodCountCheck">
|
||||||
<property name="maxTotal" value="30"/>
|
<property name="maxTotal" value="10"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.MethodLengthCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.MethodLengthCheck">
|
||||||
<property name="max" value="40"/>
|
<property name="max" value="30"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck"/>
|
||||||
|
|
2
set-version.sh
Normal file → Executable file
2
set-version.sh
Normal file → Executable file
|
@ -12,4 +12,4 @@ NEXT=$2
|
||||||
echo Updating version from $CURRENT to $NEXT
|
echo Updating version from $CURRENT to $NEXT
|
||||||
|
|
||||||
./mvnw versions:set -DnewVersion=$NEXT
|
./mvnw versions:set -DnewVersion=$NEXT
|
||||||
perl -p -i -e "s,$CURRENT</,$NEXT</," builder/pom.xml builder/src/main/resources/README-template.md regressions/pom.xml ruleset/pom.xml tile/pom.xml tile/tile.xml
|
perl -p -i -e "s,$CURRENT</,$NEXT</," builder/pom.xml builder/src/main/resources/README-template.md ruleset/pom.xml tile/pom.xml tile/tile.xml
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
language: java
|
|
||||||
jdk:
|
|
||||||
- oraclejdk8
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- "$HOME/.m2"
|
|
||||||
install: true
|
|
||||||
script: "./mvnw clean install"
|
|
11
tile/pom.xml
11
tile/pom.xml
|
@ -5,20 +5,20 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.kemitix</groupId>
|
<groupId>net.kemitix</groupId>
|
||||||
<artifactId>kemitix-parent</artifactId>
|
<artifactId>kemitix-parent</artifactId>
|
||||||
<version>5.0.3</version>
|
<version>5.1.0</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>net.kemitix.checkstyle</groupId>
|
<groupId>net.kemitix.checkstyle</groupId>
|
||||||
<artifactId>tile</artifactId>
|
<artifactId>tile</artifactId>
|
||||||
<version>4.0.1</version>
|
<version>4.1.0</version>
|
||||||
|
|
||||||
<packaging>tile</packaging>
|
<packaging>tile</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
<tiles-maven-plugin.version>2.11</tiles-maven-plugin.version>
|
||||||
<kemitix-tiles.version>0.2.0</kemitix-tiles.version>
|
<kemitix-tiles.version>0.8.1</kemitix-tiles.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -30,8 +30,7 @@
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<tiles>
|
<tiles>
|
||||||
<tile>net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version}</tile>
|
<tile>net.kemitix.tiles:maven-plugins:${kemitix-tiles.version}</tile>
|
||||||
<tile>net.kemitix.tiles:release-tile:${kemitix-tiles.version}</tile>
|
|
||||||
</tiles>
|
</tiles>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<project>
|
<project>
|
||||||
<properties>
|
<properties>
|
||||||
<maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version>
|
<maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version>
|
||||||
<checkstyle.version>8.6</checkstyle.version>
|
<checkstyle.version>8.10</checkstyle.version>
|
||||||
<sevntu.version>1.26.0</sevntu.version>
|
<sevntu.version>1.29.0</sevntu.version>
|
||||||
<kemitix.checkstyle.ruleset.version>4.0.1</kemitix.checkstyle.ruleset.version>
|
<kemitix.checkstyle.ruleset.version>4.0.1</kemitix.checkstyle.ruleset.version>
|
||||||
<kemitix.checkstyle.ruleset.level>5-complexity</kemitix.checkstyle.ruleset.level>
|
<kemitix.checkstyle.ruleset.level>5-complexity</kemitix.checkstyle.ruleset.level>
|
||||||
<kemitix.checkstyle.ruleset.location>net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml</kemitix.checkstyle.ruleset.location>
|
<kemitix.checkstyle.ruleset.location>net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml</kemitix.checkstyle.ruleset.location>
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
box: maven:3.5.0-jdk-8
|
|
||||||
|
|
||||||
build:
|
|
||||||
steps:
|
|
||||||
- xenoterracide/maven:
|
|
||||||
goals: clean install
|
|
Loading…
Reference in a new issue