commit
9f6f2646b1
40 changed files with 261 additions and 1414 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,6 +4,8 @@
|
||||||
*.ear
|
*.ear
|
||||||
*.zip
|
*.zip
|
||||||
|
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
|
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule ".travis-support"]
|
||||||
|
path = .travis-support
|
||||||
|
url = https://github.com/kemitix/kemitix-travis-support.git
|
1
.travis-support
Submodule
1
.travis-support
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit b8593e541ba9a11447fa9559a83e5f99097ca4d2
|
11
.travis.yml
11
.travis.yml
|
@ -7,11 +7,12 @@ cache:
|
||||||
install: true
|
install: true
|
||||||
script: "./mvnw clean install"
|
script: "./mvnw clean install"
|
||||||
after_success:
|
after_success:
|
||||||
- "./travis-ci/travis-coveralls-report.sh"
|
- sh .travis-support/coveralls.sh
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
- "./travis-ci/travis-deploy.sh"
|
deploy:
|
||||||
|
provider: script
|
||||||
|
script: sh .travis-support/deploy.sh
|
||||||
|
on:
|
||||||
|
branch: master
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- secure: Aq+1PsvZoRPi4/yvKfF9b7PFPb6BGwjBKwva3nJznT7yDO7H2QjpZEs8csvnobdNf5zCdSJGifcxhQjKpwD1YF5Y3Szw9bSFBE0UsNmuJY0Ls92fqSwEJmfs81gEs2VLgdXTP1jt4t2hzjyY77C1t3wQYjLebZ25tza2N6cl8xQDL9uq35kdgfE3oy/Alws7Kgf2rO7N5BibKTIau0a4qcRJIIOK/2/8hhCt/9ER9SgDwwmNeicfDQ9afau90ONqoKszhIiiOY3m2ml8UiZTCATTYr8FsiEd704sMWiWiwXoH1gCII8YZAvBv7gh2ZY6PC/BOaaqXpA3BULOFX2ROtauLFnFJANXUL7lHaclzXMjf/hLQBWgFeYomud1f7zaN4uS2ow+PdgMGeeh8qAv9Iri5u6+hS3sm4XPyIkFK9mlnLLVMDEtZkZZf4+YzyUp0Fxk02ShfBdjTvfWo7A1+RFuR+gy5lIYpqhof1AHEKiINFvs7mgmQarvNVbm+qT19vHwhvE5umovWw+k1vykO3/ulzE6u36aeNGpqCzEXmDRbxzmigDsQA0hMuiiaLcS7uh2YrSkG8N96Pd07U0DqiaCrTB7zqaBmCfMlLtdd2pJMyQXLksyxaGbxTcgC13s2ROUfuOzk40sA0nByILveht+NqrCxlYcwitWi/8ITZU=
|
|
||||||
- secure: fyBNtzMfKiERJWfvfSPr6jk/TKwHIM3H7EAjtr2SY18cyLz/oHVxp99x2pOkyZz5RVtMapmbKIil0eXP3+Ws2YqOTYHNPBCLNVSmkgBzB4NLiOYWE91OytFVDxeotRT++NvEkWXSjnFtfhpBw1UEfWyP/lkdA+qeOQwfh66mUydQ1Ic3xt/88GGvZwhuNk5fWW0UmlIQY5g7QnLZKf24w4vkkhhswDieNPUvNDjpv1ZamvTYYB8dhtzWmwOY6pTrEOXlFg7g8pgFA5IQHSeFSPKZEMdERkffeN5acXDA6cUsinzuwHcJ7ASlmbw2jWLwwyZFIDI+qDpJ1qK9XBg9eHNMiDlM9FMeEsHOy2CeFytnvVcJEhFlqdWeH8lIa1jNO8p4+5njJI1/kIjVXIzihuljYgenbGxhPZ+gyD1YtmFdu2zt3MLIhysdc92CCR+W46QPLWpI2tufaPm7lQ65/hLReNF6uS+EAi9d45kfczizDpCOn+oqxEYe5zLsZB0Di3zj3cEHxBqq46ROKuLCeXGnREro5H2YTz+HPOI7KVyYF+nvlEproGfcLImH9sxCQFaYXAU5Bv5fgOFa1qmMN3Ku+oMsmuo6LIJPclxcRjT7iy1Qxokgqe9A+fQEMhM24URndxjd8nu444taSm5/xxxF04gxM/Zk07/WXxNfuGo=
|
|
||||||
- secure: RYNyODJtcTu/A2pWOLGOfrcR3aiqFUpKk8NqScHlEX1uB1XoRlXl2EoXwD+8v4CPdTkEisz1cPUwFGMI+aq5qCN724Hyefvon5RV1bqbntDzbt8uaOaCVb2V0yXsrRXM4HHhbmEjZWlvZJtxf2Un9yxCOly3VOZh9UUMv/8sf+lp5ijOzFlLbcOXc5d+DbqhuuP7rypp34OXnDV6jo4qaeEbcucruo9ZS1kQ4vRKWQSpDCOuxYOaYF2lS2T3LNnrfhH/fXgwx1K/oSytwVZAw2Qcx+5m0A9lwB4c6Cn3BiJUv7QaCduWXhoMxudXh1spT6WzGFw8HqypmvfLt2+DQtUOKFlJz76Q8w+GpwJCtzbXNd6KHqIeL3o3Tq48FViB06aN4NceaFyj3POM+QEkozNao+DguKVaB5gzOFmPTC8QCf8U/2HRfyw2/2tAgK27loaolXumCg/yfvr0vPsX6B3dAAC2gbWemaiZxkue/Wivkx+3dRJvutcHBs/dkhvxL6nkOW4rY79dHcnl33Lmyf5UWkkoNkrcT4r+1eXYB5nRAkAnwVK8xlpMVTQNB6b2TXnrvqhoi2wTbWNyu0rSTDifgY1NTYGqA0w5hlZtUi7xqxa/i8qBvOJXX4wrvCL8JCDEvzzqJ4MJ6Ajwi67TVPjf8vb8nMW1hETDeuJ20jY=
|
|
||||||
|
|
11
CHANGELOG
11
CHANGELOG
|
@ -1,6 +1,17 @@
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
3.4.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* Disable Header check
|
||||||
|
* Remove requirement for `@author` in Type Javadoc
|
||||||
|
* Disable AvoidStarImport check
|
||||||
|
* Disable AvoidStaticImport check
|
||||||
|
* Disable JavadocPackage check
|
||||||
|
* Upgrade `checkstyle` to 8.7
|
||||||
|
* Upgrade `sevntu-checkstyle` to 1.26.0
|
||||||
|
|
||||||
3.3.0
|
3.3.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
@ -6,32 +6,60 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.kemitix</groupId>
|
<groupId>net.kemitix</groupId>
|
||||||
<artifactId>kemitix-checkstyle-ruleset-parent</artifactId>
|
<artifactId>kemitix-parent</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>5.0.3</version>
|
||||||
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>kemitix-checkstyle-ruleset-builder</artifactId>
|
<groupId>net.kemitix.checkstyle</groupId>
|
||||||
|
<artifactId>ruleset-builder</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
|
||||||
<name>Kemitix Checkstyle :: Ruleset :: Builder</name>
|
<properties>
|
||||||
<description>Builder for the Kemitix Checkstyle Ruleset</description>
|
<java.version>1.8</java.version>
|
||||||
|
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
||||||
|
<kemitix-tiles.version>0.2.0</kemitix-tiles.version>
|
||||||
|
|
||||||
<issueManagement>
|
<checkstyle.version>8.7</checkstyle.version>
|
||||||
<url>https://github.com/kemitix/kemitix-checkstyle-ruleset/issues</url>
|
<sevntu.version>1.26.0</sevntu.version>
|
||||||
<system>GitHub Issues</system>
|
<lombok.version>1.16.18</lombok.version>
|
||||||
</issueManagement>
|
<spring-platform.version>Brussels-SR6</spring-platform.version>
|
||||||
|
<spring-boot.version>1.5.9.RELEASE</spring-boot.version>
|
||||||
|
<mapstream.version>2.3.5</mapstream.version>
|
||||||
|
<map-builder.version>1.0.0</map-builder.version>
|
||||||
|
<mockito.version>2.13.0</mockito.version>
|
||||||
|
<assertj.version>3.9.0</assertj.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<scm>
|
<dependencyManagement>
|
||||||
<url>https://github.com/kemitix/kemitix-checkstyle-ruleset</url>
|
<dependencies>
|
||||||
<connection>scm:git:git://github.com/kemitix/kemitix-checkstyle-ruleset.git</connection>
|
<dependency>
|
||||||
<developerConnection>scm:git:git@github.com:kemitix/kemitix-checkstyle-ruleset.git</developerConnection>
|
<groupId>io.spring.platform</groupId>
|
||||||
</scm>
|
<artifactId>platform-bom</artifactId>
|
||||||
|
<version>${spring-platform.version}</version>
|
||||||
<url>https://github.com/kemitix/kemitix-checkstyle-ruleset</url>
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
<inceptionYear>2016</inceptionYear>
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<version>${mockito.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
@ -54,6 +82,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.speedment.common</groupId>
|
<groupId>com.speedment.common</groupId>
|
||||||
<artifactId>mapstream</artifactId>
|
<artifactId>mapstream</artifactId>
|
||||||
|
<version>${mapstream.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -63,21 +92,43 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.andrz</groupId>
|
<groupId>me.andrz</groupId>
|
||||||
<artifactId>map-builder</artifactId>
|
<artifactId>map-builder</artifactId>
|
||||||
|
<version>${map-builder.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.puppycrawl.tools</groupId>
|
<groupId>com.puppycrawl.tools</groupId>
|
||||||
<artifactId>checkstyle</artifactId>
|
<artifactId>checkstyle</artifactId>
|
||||||
|
<version>${checkstyle.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.sevntu-checkstyle</groupId>
|
<groupId>com.github.sevntu-checkstyle</groupId>
|
||||||
<artifactId>sevntu-checks</artifactId>
|
<artifactId>sevntu-checks</artifactId>
|
||||||
|
<version>${sevntu.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<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:enforcer-tile:${kemitix-tiles.version}</tile>
|
||||||
|
<tile>net.kemitix.tiles:compiler-tile:${kemitix-tiles.version}</tile>
|
||||||
|
<!--<tile>net.kemitix.tiles:checkstyle-tile:${kemitix-tiles.version}</tile>-->
|
||||||
|
<tile>net.kemitix.tiles:huntbugs-tile:${kemitix-tiles.version}</tile>
|
||||||
|
<tile>net.kemitix.tiles:pmd-tile:${kemitix-tiles.version}</tile>
|
||||||
|
<tile>net.kemitix.tiles:testing-tile:${kemitix-tiles.version}</tile>
|
||||||
|
<tile>net.kemitix.tiles:coverage-tile:${kemitix-tiles.version}</tile>
|
||||||
|
<tile>net.kemitix.tiles:pitest-tile:${kemitix-tiles.version}</tile>
|
||||||
|
</tiles>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
@ -88,18 +139,11 @@
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>
|
<goal>repackage</goal>
|
||||||
repackage
|
|
||||||
</goal>
|
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.eluder.coveralls</groupId>
|
|
||||||
<artifactId>coveralls-maven-plugin</artifactId>
|
|
||||||
<version>${coveralls-maven-plugin.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
package net.kemitix.checkstyle.ruleset.builder;
|
package net.kemitix.checkstyle.ruleset.builder;
|
||||||
|
|
||||||
import com.speedment.common.mapstream.MapStream;
|
import com.speedment.common.mapstream.MapStream;
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
@ -58,13 +57,13 @@ class CheckstyleWriter implements CommandLineRunner {
|
||||||
private final RuleClassLocator ruleClassLocator;
|
private final RuleClassLocator ruleClassLocator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(final String... args) throws Exception {
|
public void run(final String... args) {
|
||||||
Stream.of(RuleLevel.values())
|
Stream.of(RuleLevel.values())
|
||||||
.filter(level -> !level.equals(RuleLevel.UNSPECIFIED))
|
.filter(level -> !level.equals(RuleLevel.UNSPECIFIED))
|
||||||
.forEach(this::writeCheckstyleFile);
|
.forEach(this::writeCheckstyleFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeCheckstyleFile(@NonNull final RuleLevel ruleLevel) {
|
private void writeCheckstyleFile(final RuleLevel ruleLevel) {
|
||||||
val xmlFile = outputProperties.getDirectory()
|
val xmlFile = outputProperties.getDirectory()
|
||||||
.resolve(outputProperties.getRulesetFiles()
|
.resolve(outputProperties.getRulesetFiles()
|
||||||
.get(ruleLevel));
|
.get(ruleLevel));
|
||||||
|
|
|
@ -28,6 +28,7 @@ import javax.annotation.PostConstruct;
|
||||||
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.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ public class DefaultRuleClassLocator implements RuleClassLocator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCanonicalClassName(final RuleSource source, final String name) {
|
private String getCanonicalClassName(final RuleSource source, final String name) {
|
||||||
|
Objects.requireNonNull(checkClasses, "init() method not called");
|
||||||
return checkClasses.get(source)
|
return checkClasses.get(source)
|
||||||
.stream()
|
.stream()
|
||||||
.sorted()
|
.sorted()
|
||||||
|
|
|
@ -101,14 +101,14 @@ rules:
|
||||||
name: AvoidStarImport
|
name: AvoidStarImport
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
level: LAYOUT
|
level: LAYOUT
|
||||||
enabled: true
|
enabled: false
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport
|
uri: http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport
|
||||||
-
|
-
|
||||||
name: AvoidStaticImport
|
name: AvoidStaticImport
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
level: COMPLEXITY
|
level: COMPLEXITY
|
||||||
enabled: true
|
enabled: false
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_imports.html#AvoidStaticImport
|
uri: http://checkstyle.sourceforge.net/config_imports.html#AvoidStaticImport
|
||||||
properties:
|
properties:
|
||||||
|
@ -324,7 +324,7 @@ rules:
|
||||||
name: Header
|
name: Header
|
||||||
parent: CHECKER
|
parent: CHECKER
|
||||||
level: LAYOUT
|
level: LAYOUT
|
||||||
enabled: true
|
enabled: false
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_header.html#Header
|
uri: http://checkstyle.sourceforge.net/config_header.html#Header
|
||||||
properties:
|
properties:
|
||||||
|
@ -427,7 +427,7 @@ rules:
|
||||||
name: JavadocPackage
|
name: JavadocPackage
|
||||||
parent: CHECKER
|
parent: CHECKER
|
||||||
level: JAVADOC
|
level: JAVADOC
|
||||||
enabled: true
|
enabled: false
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage
|
uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage
|
||||||
-
|
-
|
||||||
|
@ -451,8 +451,6 @@ rules:
|
||||||
enabled: true
|
enabled: true
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocType
|
uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocType
|
||||||
properties:
|
|
||||||
authorFormat: ^.+ (\S+@[\S.]+)$
|
|
||||||
-
|
-
|
||||||
name: JavaNCSS
|
name: JavaNCSS
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
|
|
||||||
Checks the format for Javadoc for classes and enums. Javadoc must be present, not have any unknown tags and not missing any `@param` tags. The `@author` tag must have a name and, in brackets, an email address.
|
Checks the format for Javadoc for classes and enums. Javadoc must be present, not have any unknown tags and not missing any `@param` tags.
|
||||||
|
|
|
@ -7,8 +7,6 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -24,6 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link CheckstyleWriter}.
|
* Tests for {@link CheckstyleWriter}.
|
||||||
|
@ -58,12 +57,10 @@ public class CheckstyleWriterTest {
|
||||||
|
|
||||||
private Path outputDirectory;
|
private Path outputDirectory;
|
||||||
|
|
||||||
@Mock
|
private RuleClassLocator ruleClassLocator = mock(RuleClassLocator.class);
|
||||||
private RuleClassLocator ruleClassLocator;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
ruleName = "RegexpOnFilename";
|
ruleName = "RegexpOnFilename";
|
||||||
ruleClassname = "com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameCheck";
|
ruleClassname = "com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameCheck";
|
||||||
outputProperties = new OutputProperties();
|
outputProperties = new OutputProperties();
|
||||||
|
@ -90,7 +87,7 @@ public class CheckstyleWriterTest {
|
||||||
given(ruleClassLocator.apply(any())).willReturn(ruleClassname);
|
given(ruleClassLocator.apply(any())).willReturn(ruleClassname);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map.Entry<RuleLevel, String> getOutputFile(final RuleLevel level) throws IOException {
|
private Map.Entry<RuleLevel, String> getOutputFile(final RuleLevel level) {
|
||||||
final String xmlFile = String.format("checkstyle-%s.xml", level.toString());
|
final String xmlFile = String.format("checkstyle-%s.xml", level.toString());
|
||||||
return new AbstractMap.SimpleImmutableEntry<>(level, xmlFile);
|
return new AbstractMap.SimpleImmutableEntry<>(level, xmlFile);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +199,7 @@ public class CheckstyleWriterTest {
|
||||||
|
|
||||||
// throw RTE if template not found
|
// throw RTE if template not found
|
||||||
@Test
|
@Test
|
||||||
public void throwRteIfTemplateNotFound() throws Exception {
|
public void throwRteIfTemplateNotFound() {
|
||||||
//given
|
//given
|
||||||
templateProperties.setCheckstyleXml(Paths.get("garbage"));
|
templateProperties.setCheckstyleXml(Paths.get("garbage"));
|
||||||
//when
|
//when
|
||||||
|
@ -214,7 +211,7 @@ public class CheckstyleWriterTest {
|
||||||
|
|
||||||
// throw RTE if error writing file
|
// throw RTE if error writing file
|
||||||
@Test
|
@Test
|
||||||
public void throwRteIfErrorWritingFile() throws Exception {
|
public void throwRteIfErrorWritingFile() {
|
||||||
//given
|
//given
|
||||||
final String imaginary = String.join(FILE_SEPARATOR, "", "..", "imaginary");
|
final String imaginary = String.join(FILE_SEPARATOR, "", "..", "imaginary");
|
||||||
outputProperties.setDirectory(Paths.get(imaginary));
|
outputProperties.setDirectory(Paths.get(imaginary));
|
||||||
|
|
|
@ -2,14 +2,15 @@ package net.kemitix.checkstyle.ruleset.builder;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatNullPointerException;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link DefaultRuleClassLocator}.
|
* Tests for {@link DefaultRuleClassLocator}.
|
||||||
|
@ -20,17 +21,15 @@ public class DefaultRuleClassLocatorTest {
|
||||||
|
|
||||||
private DefaultRuleClassLocator subject;
|
private DefaultRuleClassLocator subject;
|
||||||
|
|
||||||
@Mock
|
private PackageScanner packageScanner = mock(PackageScanner.class);
|
||||||
private PackageScanner packageScanner;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
subject = new DefaultRuleClassLocator(packageScanner);
|
subject = new DefaultRuleClassLocator(packageScanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canLookupRule() {
|
public void canLookupRuleWithClassNameEndingInCheck() {
|
||||||
//given
|
//given
|
||||||
final String rulename = "RegexpOnFilename";
|
final String rulename = "RegexpOnFilename";
|
||||||
final String expected = "com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameCheck";
|
final String expected = "com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameCheck";
|
||||||
|
@ -46,6 +45,47 @@ public class DefaultRuleClassLocatorTest {
|
||||||
assertThat(result).isEqualTo(expected);
|
assertThat(result).isEqualTo(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canLookupRuleWithClassNameMatchingRuleName() {
|
||||||
|
//given
|
||||||
|
final String rulename = "RegexpOnFilename";
|
||||||
|
final String expected = "com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilename";
|
||||||
|
final List<String> checkstyleClasses = Collections.singletonList(expected);
|
||||||
|
final List<String> sevntuClasses = Collections.emptyList();
|
||||||
|
given(packageScanner.apply(RuleSource.CHECKSTYLE)).willReturn(checkstyleClasses.stream());
|
||||||
|
given(packageScanner.apply(RuleSource.SEVNTU)).willReturn(sevntuClasses.stream());
|
||||||
|
subject.init();
|
||||||
|
final Rule rule = createCheckstyleRule(rulename);
|
||||||
|
//when
|
||||||
|
final String result = subject.apply(rule);
|
||||||
|
//then
|
||||||
|
assertThat(result).isEqualTo(expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void throwsExceptionWhenCheckstyleClassNotFound() {
|
||||||
|
//given
|
||||||
|
final String rulename = "RegexpOnFilename";
|
||||||
|
final String expected = "com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameNoMatch";
|
||||||
|
final List<String> checkstyleClasses = Collections.singletonList(expected);
|
||||||
|
final List<String> sevntuClasses = Collections.emptyList();
|
||||||
|
given(packageScanner.apply(RuleSource.CHECKSTYLE)).willReturn(checkstyleClasses.stream());
|
||||||
|
given(packageScanner.apply(RuleSource.SEVNTU)).willReturn(sevntuClasses.stream());
|
||||||
|
subject.init();
|
||||||
|
final Rule rule = createCheckstyleRule(rulename);
|
||||||
|
//then
|
||||||
|
assertThatThrownBy(() -> subject.apply(rule))
|
||||||
|
.isInstanceOf(CheckstyleClassNotFoundException.class)
|
||||||
|
.hasMessage("No class found to implement RegexpOnFilename");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void throwsNullPointerExceptionWhenInitNotCalled() {
|
||||||
|
assertThatNullPointerException()
|
||||||
|
.isThrownBy(() -> subject.apply(new Rule()))
|
||||||
|
.withMessage("init() method not called");
|
||||||
|
}
|
||||||
|
|
||||||
private Rule createCheckstyleRule(final String rulename) {
|
private Rule createCheckstyleRule(final String rulename) {
|
||||||
final Rule rule = new Rule();
|
final Rule rule = new Rule();
|
||||||
rule.setSource(RuleSource.CHECKSTYLE);
|
rule.setSource(RuleSource.CHECKSTYLE);
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package net.kemitix.checkstyle.ruleset.builder;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
public class RuleLevelTest {
|
||||||
|
|
||||||
|
private final String[] ruleLevelStrings =
|
||||||
|
{"DISABLED", "LAYOUT", "NAMING", "JAVADOC", "TWEAKS", "COMPLEXITY", "UNSPECIFIED"};
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valuesToString() {
|
||||||
|
assertThat(Stream.of(RuleLevel.values())
|
||||||
|
.map(RuleLevel::toString)).containsExactly(ruleLevelStrings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void stringValueOf() {
|
||||||
|
assertThat(Stream.of(ruleLevelStrings)
|
||||||
|
.map(RuleLevel::valueOf)).containsExactly(RuleLevel.values());
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,16 +15,16 @@ public class RulesPropertiesTest {
|
||||||
private RulesProperties rulesProperties;
|
private RulesProperties rulesProperties;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() {
|
||||||
rulesProperties = new RulesProperties();
|
rulesProperties = new RulesProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getEmpty() throws Exception {
|
public void getEmpty() {
|
||||||
assertThat(rulesProperties.getRules()).isEmpty();
|
assertThat(rulesProperties.getRules()).isEmpty();
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void getContent() throws Exception {
|
public void getContent() {
|
||||||
//given
|
//given
|
||||||
final Rule rule = new Rule();
|
final Rule rule = new Rule();
|
||||||
//when
|
//when
|
||||||
|
|
BIN
codesigning.asc.enc
Normal file
BIN
codesigning.asc.enc
Normal file
Binary file not shown.
|
@ -1,74 +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-checkstyle-ruleset-parent</artifactId>
|
|
||||||
<version>3.3.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>kemitix-checkstyle-ruleset-maven-plugin</artifactId>
|
|
||||||
<packaging>maven-plugin</packaging>
|
|
||||||
<name>Kemitix Checkstyle :: Ruleset :: Plugin</name>
|
|
||||||
<description>Checkstyle configuration using the Kemitix Checkstyle Ruleset</description>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.version>3.5.0</maven.version>
|
|
||||||
<maven-plugin-plugin.version>3.5</maven-plugin-plugin.version>
|
|
||||||
<maven-plugin-annotations.version>3.5</maven-plugin-annotations.version>
|
|
||||||
<mojo-executor.version>2.3.0</mojo-executor.version>
|
|
||||||
<map-builder.version>1.0.0</map-builder.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven</groupId>
|
|
||||||
<artifactId>maven-plugin-api</artifactId>
|
|
||||||
<version>${maven.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven</groupId>
|
|
||||||
<artifactId>maven-core</artifactId>
|
|
||||||
<version>${maven.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
|
||||||
<artifactId>maven-plugin-annotations</artifactId>
|
|
||||||
<version>${maven-plugin-annotations.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.twdata.maven</groupId>
|
|
||||||
<artifactId>mojo-executor</artifactId>
|
|
||||||
<version>${mojo-executor.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.andrz</groupId>
|
|
||||||
<artifactId>map-builder</artifactId>
|
|
||||||
<version>${map-builder.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.assertj</groupId>
|
|
||||||
<artifactId>assertj-core</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-core</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-plugin-plugin</artifactId>
|
|
||||||
<version>${maven-plugin-plugin.version}</version>
|
|
||||||
</plugin><!-- maven-plugin-plugin -->
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
|
@ -1,53 +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.ruleset.plugin;
|
|
||||||
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
|
||||||
import org.apache.maven.plugin.BuildPluginManager;
|
|
||||||
import org.apache.maven.project.MavenProject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration for performing a Checkstyle Check.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Builder
|
|
||||||
class CheckConfiguration {
|
|
||||||
|
|
||||||
private MavenProject mavenProject;
|
|
||||||
|
|
||||||
private MavenSession mavenSession;
|
|
||||||
|
|
||||||
private ArtifactRepository artifactRepository;
|
|
||||||
|
|
||||||
private BuildPluginManager pluginManager;
|
|
||||||
|
|
||||||
private String rulesetVersion;
|
|
||||||
|
|
||||||
private String sourceDirectory;
|
|
||||||
|
|
||||||
private String level;
|
|
||||||
}
|
|
|
@ -1,99 +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.ruleset.plugin;
|
|
||||||
|
|
||||||
import lombok.Setter;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
|
||||||
import org.apache.maven.model.Build;
|
|
||||||
import org.apache.maven.model.Plugin;
|
|
||||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
|
||||||
import org.apache.maven.plugin.BuildPluginManager;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
|
||||||
import org.apache.maven.plugins.annotations.Component;
|
|
||||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
|
||||||
import org.apache.maven.plugins.annotations.Mojo;
|
|
||||||
import org.apache.maven.plugins.annotations.Parameter;
|
|
||||||
import org.apache.maven.project.MavenProject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs the Checkstyle Maven Plugin with the Kemitix Checkstyle Ruleset.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
@Mojo(name = "check", defaultPhase = LifecyclePhase.VALIDATE)
|
|
||||||
public class CheckMojo extends AbstractMojo {
|
|
||||||
|
|
||||||
private static final String KEMITIX_GROUPID = "net.kemitix";
|
|
||||||
|
|
||||||
private static final String KEMITIX_ARTIFACTID = "kemitix-checkstyle-ruleset";
|
|
||||||
|
|
||||||
@Setter
|
|
||||||
private CheckstyleExecutor checkstyleExecutor =
|
|
||||||
new DefaultCheckstyleExecutor(new DefaultPluginExecutor(), new MavenXpp3Reader());
|
|
||||||
|
|
||||||
@Setter
|
|
||||||
@Parameter(defaultValue = "${project}", readonly = true)
|
|
||||||
private MavenProject mavenProject;
|
|
||||||
|
|
||||||
@Setter
|
|
||||||
@Parameter(defaultValue = "${session}", readonly = true)
|
|
||||||
private MavenSession mavenSession;
|
|
||||||
|
|
||||||
@Setter
|
|
||||||
@Parameter(defaultValue = "${localRepository}", readonly = true, required = true)
|
|
||||||
private ArtifactRepository artifactRepository;
|
|
||||||
|
|
||||||
@Parameter(name = "level", defaultValue = "5-complexity", readonly = true)
|
|
||||||
private String level = "5-complexity";
|
|
||||||
|
|
||||||
@Setter
|
|
||||||
@Component
|
|
||||||
private BuildPluginManager pluginManager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void execute() throws MojoExecutionException, MojoFailureException {
|
|
||||||
checkstyleExecutor.setLog(getLog());
|
|
||||||
CheckConfiguration config = getCheckConfiguration();
|
|
||||||
checkstyleExecutor.performCheck(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CheckConfiguration getCheckConfiguration() {
|
|
||||||
final Plugin rulesetPlugin = getRulesetPlugin();
|
|
||||||
final Build build = mavenProject.getBuild();
|
|
||||||
return CheckConfiguration.builder()
|
|
||||||
.mavenProject(mavenProject)
|
|
||||||
.mavenSession(mavenSession)
|
|
||||||
.artifactRepository(artifactRepository)
|
|
||||||
.pluginManager(pluginManager)
|
|
||||||
.rulesetVersion(rulesetPlugin.getVersion())
|
|
||||||
.sourceDirectory(build.getSourceDirectory())
|
|
||||||
.level(level)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Plugin getRulesetPlugin() {
|
|
||||||
return mavenProject.getPlugin(KEMITIX_GROUPID + ":" + KEMITIX_ARTIFACTID + "-maven-plugin");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +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.ruleset.plugin;
|
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
|
||||||
import org.apache.maven.plugin.logging.Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes the Checkstyle plugin.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
interface CheckstyleExecutor {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute Checkstyle Check.
|
|
||||||
*
|
|
||||||
* @param configuration The Configuration
|
|
||||||
*
|
|
||||||
* @throws MojoExecutionException on execution error
|
|
||||||
* @throws MojoFailureException on execution failure
|
|
||||||
*/
|
|
||||||
void performCheck(CheckConfiguration configuration) throws MojoExecutionException, MojoFailureException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the logger to use.
|
|
||||||
*
|
|
||||||
* @param log the logger.
|
|
||||||
*/
|
|
||||||
void setLog(Log log);
|
|
||||||
}
|
|
|
@ -1,186 +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.ruleset.plugin;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.val;
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.artifact.DefaultArtifact;
|
|
||||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
|
||||||
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.model.Model;
|
|
||||||
import org.apache.maven.model.Plugin;
|
|
||||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
|
||||||
import org.apache.maven.plugin.logging.Log;
|
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
|
||||||
import org.twdata.maven.mojoexecutor.MojoExecutor;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default implementation of {@link CheckstyleExecutor}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("classfanoutcomplexity")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class DefaultCheckstyleExecutor implements CheckstyleExecutor {
|
|
||||||
|
|
||||||
private static final String CHECKSTYLE_GROUPID = "com.puppycrawl.tools";
|
|
||||||
|
|
||||||
private static final String CHECKSTYLE_ARTIFACTID = "checkstyle";
|
|
||||||
|
|
||||||
private static final String SEVNTU_GROUPID = "com.github.sevntu-checkstyle";
|
|
||||||
|
|
||||||
private static final String SEVNTU_ARTIFACTID = "sevntu-checkstyle-maven-plugin";
|
|
||||||
|
|
||||||
private static final String KEMITIX_GROUPID = "net.kemitix";
|
|
||||||
|
|
||||||
private static final String KEMITIX_ARTIFACTID = "kemitix-checkstyle-ruleset";
|
|
||||||
|
|
||||||
private static final String APACHE_PLUGIN_GROUPID = "org.apache.maven.plugins";
|
|
||||||
|
|
||||||
private static final String APACHE_PLUGIN_ARTIFACTID = "maven-checkstyle-plugin";
|
|
||||||
|
|
||||||
private static final String CONFIG_LOCATION = "configLocation";
|
|
||||||
|
|
||||||
private static final String SOURCE_DIR = "sourceDirectory";
|
|
||||||
|
|
||||||
private static final ArtifactHandler POM_ARTIFACT_HANDLER = new DefaultArtifactHandler("pom");
|
|
||||||
|
|
||||||
private static final String PLUGIN_ARTIFACT_ID = KEMITIX_ARTIFACTID + "-parent";
|
|
||||||
|
|
||||||
private final PluginExecutor pluginExecutor;
|
|
||||||
|
|
||||||
private final MavenXpp3Reader mavenXpp3Reader;
|
|
||||||
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private Log log;
|
|
||||||
|
|
||||||
private String rulesetVersion;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void performCheck(final CheckConfiguration config)
|
|
||||||
throws MojoExecutionException, MojoFailureException {
|
|
||||||
rulesetVersion = config.getRulesetVersion();
|
|
||||||
val properties = getProperties(config.getArtifactRepository());
|
|
||||||
|
|
||||||
// configure
|
|
||||||
val checkstylePlugin = getPlugin(properties);
|
|
||||||
final String sourceDirectory = config.getSourceDirectory();
|
|
||||||
final String level = config.getLevel();
|
|
||||||
info("Ruleset: %s", level);
|
|
||||||
final String configFile = String.format("net/kemitix/checkstyle-%s.xml", level);
|
|
||||||
final Xpp3Dom configuration = pluginExecutor.configuration(pluginExecutor.element(CONFIG_LOCATION, configFile),
|
|
||||||
pluginExecutor.element(SOURCE_DIR, sourceDirectory)
|
|
||||||
);
|
|
||||||
final MojoExecutor.ExecutionEnvironment environment = pluginExecutor.executionEnvironment(config);
|
|
||||||
|
|
||||||
// run
|
|
||||||
pluginExecutor.executeMojo(checkstylePlugin, "check", configuration, environment);
|
|
||||||
info("Checkstyle complete");
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getProperty(final Properties properties, final String key) {
|
|
||||||
val property = properties.getProperty(key);
|
|
||||||
debug("%s: %s", key, property);
|
|
||||||
return property;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Plugin getPlugin(final Properties properties) {
|
|
||||||
// get versions from pom.xml properties
|
|
||||||
val pluginVersion = getProperty(properties, "maven-checkstyle-plugin.version");
|
|
||||||
val checkstyleVersion = getProperty(properties, "checkstyle.version");
|
|
||||||
val sevntuVersion = getProperty(properties, "sevntu.version");
|
|
||||||
info("Checkstyle %s (plugin: %s, sevntu: %s, ruleset: %s)", checkstyleVersion,
|
|
||||||
pluginVersion, sevntuVersion, rulesetVersion
|
|
||||||
);
|
|
||||||
|
|
||||||
// create checkstyle dependencies
|
|
||||||
val checkstyle = getCheckstyleDependency(checkstyleVersion);
|
|
||||||
val sevntu = getSevntuDependency(sevntuVersion);
|
|
||||||
val ruleset = getRulesetDependency();
|
|
||||||
final List<Dependency> dependencies = pluginExecutor.dependencies(checkstyle, sevntu, ruleset);
|
|
||||||
|
|
||||||
return pluginExecutor.plugin(APACHE_PLUGIN_GROUPID, APACHE_PLUGIN_ARTIFACTID, pluginVersion, dependencies);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dependency getRulesetDependency() {
|
|
||||||
return pluginExecutor.dependency(KEMITIX_GROUPID, KEMITIX_ARTIFACTID, rulesetVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dependency getSevntuDependency(final String sevntuVersion) {
|
|
||||||
return pluginExecutor.dependency(SEVNTU_GROUPID, SEVNTU_ARTIFACTID, sevntuVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dependency getCheckstyleDependency(final String checkstyleVersion) {
|
|
||||||
return pluginExecutor.dependency(CHECKSTYLE_GROUPID, CHECKSTYLE_ARTIFACTID, checkstyleVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Properties getProperties(final ArtifactRepository artifactRepository) throws MojoFailureException {
|
|
||||||
// load properties from the plugin pom.xml
|
|
||||||
final Artifact pluginArtifact = getPluginArtifact(artifactRepository);
|
|
||||||
try {
|
|
||||||
final File pomFile = pluginArtifact.getFile();
|
|
||||||
return parsePomFile(pomFile).getProperties();
|
|
||||||
} catch (XmlPullParserException | IOException e) {
|
|
||||||
throw new MojoFailureException("Can't load properties from plugin's pom.xml", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model parsePomFile(final File pomFile) throws IOException, XmlPullParserException {
|
|
||||||
final Reader pomReader = new FileReader(pomFile);
|
|
||||||
return mavenXpp3Reader.read(pomReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Artifact getPluginArtifact(final ArtifactRepository artifactRepository) {
|
|
||||||
final Artifact templateArtifact = getRulesetArtifactTemplate();
|
|
||||||
return artifactRepository.find(templateArtifact);
|
|
||||||
}
|
|
||||||
|
|
||||||
private DefaultArtifact getRulesetArtifactTemplate() {
|
|
||||||
return new DefaultArtifact(KEMITIX_GROUPID, PLUGIN_ARTIFACT_ID, rulesetVersion, null, "", null,
|
|
||||||
POM_ARTIFACT_HANDLER
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void info(final String format, final Object... args) {
|
|
||||||
getLog().info(String.format(format, args));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void debug(final String format, final Object... args) {
|
|
||||||
getLog().debug(String.format(format, args));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,79 +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.ruleset.plugin;
|
|
||||||
|
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.model.Plugin;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
|
||||||
import org.twdata.maven.mojoexecutor.MojoExecutor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for {@link org.twdata.maven.mojoexecutor.MojoExecutor}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net).
|
|
||||||
*/
|
|
||||||
public final class DefaultPluginExecutor implements PluginExecutor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MojoExecutor.Element element(final String key, final String value) {
|
|
||||||
return MojoExecutor.element(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Xpp3Dom configuration(final MojoExecutor.Element... elements) {
|
|
||||||
return MojoExecutor.configuration(elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MojoExecutor.ExecutionEnvironment executionEnvironment(final CheckConfiguration config) {
|
|
||||||
return MojoExecutor.executionEnvironment(
|
|
||||||
config.getMavenProject(), config.getMavenSession(), config.getPluginManager());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void executeMojo(
|
|
||||||
final Plugin plugin, final String goal, final Xpp3Dom configuration,
|
|
||||||
final MojoExecutor.ExecutionEnvironment env
|
|
||||||
) throws MojoExecutionException {
|
|
||||||
MojoExecutor.executeMojo(plugin, goal, configuration, env);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dependency dependency(final String groupid, final String artifactid, final String version) {
|
|
||||||
return MojoExecutor.dependency(groupid, artifactid, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Dependency> dependencies(final Dependency... dependencies) {
|
|
||||||
return MojoExecutor.dependencies(dependencies);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin plugin(
|
|
||||||
final String groupid, final String artifactid, final String version, final List<Dependency> dependencies
|
|
||||||
) {
|
|
||||||
return MojoExecutor.plugin(groupid, artifactid, version, dependencies);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,114 +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.ruleset.plugin;
|
|
||||||
|
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.model.Plugin;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
|
||||||
import org.twdata.maven.mojoexecutor.MojoExecutor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for wrapping calls to static methods on {@link org.twdata.maven.mojoexecutor.MojoExecutor}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net).
|
|
||||||
*/
|
|
||||||
public interface PluginExecutor {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs the element with a textual body.
|
|
||||||
*
|
|
||||||
* @param name The element name
|
|
||||||
* @param value The element text value
|
|
||||||
*
|
|
||||||
* @return The element object
|
|
||||||
*/
|
|
||||||
MojoExecutor.Element element(String name, String value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the configuration for the goal using Elements.
|
|
||||||
*
|
|
||||||
* @param elements A list of elements for the configuration section
|
|
||||||
*
|
|
||||||
* @return The elements transformed into the Maven-native XML format
|
|
||||||
*/
|
|
||||||
Xpp3Dom configuration(MojoExecutor.Element... elements);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs the {@link MojoExecutor.ExecutionEnvironment} instance fluently.
|
|
||||||
*
|
|
||||||
* @param configuration The Configuration
|
|
||||||
*
|
|
||||||
* @return The execution environment
|
|
||||||
*/
|
|
||||||
MojoExecutor.ExecutionEnvironment executionEnvironment(CheckConfiguration configuration);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entry point for executing a mojo.
|
|
||||||
*
|
|
||||||
* @param plugin The plugin to execute
|
|
||||||
* @param goal The goal to execute
|
|
||||||
* @param configuration The execution configuration
|
|
||||||
* @param env The execution environment
|
|
||||||
*
|
|
||||||
* @throws MojoExecutionException If there are any exceptions locating or executing the mojo
|
|
||||||
*/
|
|
||||||
void executeMojo(
|
|
||||||
Plugin plugin, String goal, Xpp3Dom configuration, MojoExecutor.ExecutionEnvironment env
|
|
||||||
) throws MojoExecutionException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines a dependency.
|
|
||||||
*
|
|
||||||
* @param groupId The group id
|
|
||||||
* @param artifactId The artifact id
|
|
||||||
* @param version The plugin version
|
|
||||||
*
|
|
||||||
* @return the dependency instance
|
|
||||||
*/
|
|
||||||
Dependency dependency(String groupId, String artifactId, String version);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a list of dependencies.
|
|
||||||
*
|
|
||||||
* @param dependencies the dependencies
|
|
||||||
*
|
|
||||||
* @return A list of dependencies
|
|
||||||
*/
|
|
||||||
List<Dependency> dependencies(Dependency... dependencies);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines a plugin.
|
|
||||||
*
|
|
||||||
* @param groupId The group id
|
|
||||||
* @param artifactId The artifact id
|
|
||||||
* @param version The plugin version
|
|
||||||
* @param dependencies The plugin dependencies
|
|
||||||
*
|
|
||||||
* @return The plugin instance
|
|
||||||
*/
|
|
||||||
Plugin plugin(
|
|
||||||
String groupId, String artifactId, String version, List<Dependency> dependencies
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -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.ruleset.plugin;
|
|
|
@ -1,26 +0,0 @@
|
||||||
package net.kemitix.checkstyle.ruleset.plugin;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net).
|
|
||||||
*/
|
|
||||||
public class CheckConfigurationTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void toStringCoverage() {
|
|
||||||
//given
|
|
||||||
final String rulesetVersion = "ruleset version";
|
|
||||||
final String sourceDirectory = "source directory";
|
|
||||||
//when
|
|
||||||
final String result = CheckConfiguration.builder()
|
|
||||||
.rulesetVersion(rulesetVersion)
|
|
||||||
.sourceDirectory(sourceDirectory)
|
|
||||||
.toString();
|
|
||||||
//then
|
|
||||||
assertThat(result).contains("rulesetVersion=ruleset version")
|
|
||||||
.contains("sourceDirectory=source directory");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
package net.kemitix.checkstyle.ruleset.plugin;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
|
||||||
import org.apache.maven.model.Build;
|
|
||||||
import org.apache.maven.model.Plugin;
|
|
||||||
import org.apache.maven.plugin.BuildPluginManager;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
|
||||||
import org.apache.maven.project.MavenProject;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
|
||||||
import org.mockito.Captor;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.BDDMockito.given;
|
|
||||||
import static org.mockito.BDDMockito.then;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link CheckMojo}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
public class CheckMojoTest {
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private CheckstyleExecutor checkstyleExecutor;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MavenProject mavenProject;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MavenSession mavenSession;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private ArtifactRepository artifactRepository;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private BuildPluginManager pluginManager;
|
|
||||||
|
|
||||||
@Captor
|
|
||||||
private ArgumentCaptor<CheckConfiguration> configuration;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Plugin rulesetPlugin;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Build build;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void canExecute() throws MojoFailureException, MojoExecutionException {
|
|
||||||
//given
|
|
||||||
final CheckMojo mojo = new CheckMojo();
|
|
||||||
mojo.setCheckstyleExecutor(checkstyleExecutor);
|
|
||||||
mojo.setMavenProject(mavenProject);
|
|
||||||
mojo.setMavenSession(mavenSession);
|
|
||||||
mojo.setArtifactRepository(artifactRepository);
|
|
||||||
mojo.setPluginManager(pluginManager);
|
|
||||||
given(mavenProject.getPlugin(any())).willReturn(rulesetPlugin);
|
|
||||||
given(mavenProject.getBuild()).willReturn(build);
|
|
||||||
//when
|
|
||||||
mojo.execute();
|
|
||||||
//then
|
|
||||||
then(checkstyleExecutor).should()
|
|
||||||
.performCheck(configuration.capture());
|
|
||||||
assertThat(configuration.getValue()).returns(mavenProject, CheckConfiguration::getMavenProject)
|
|
||||||
.returns(mavenSession, CheckConfiguration::getMavenSession)
|
|
||||||
.returns(artifactRepository, CheckConfiguration::getArtifactRepository)
|
|
||||||
.returns(pluginManager, CheckConfiguration::getPluginManager);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,161 +0,0 @@
|
||||||
package net.kemitix.checkstyle.ruleset.plugin;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.model.Model;
|
|
||||||
import org.apache.maven.model.Plugin;
|
|
||||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
|
||||||
import org.apache.maven.plugin.BuildPluginManager;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
|
||||||
import org.apache.maven.plugin.logging.Log;
|
|
||||||
import org.apache.maven.project.MavenProject;
|
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.rules.TemporaryFolder;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.twdata.maven.mojoexecutor.MojoExecutor;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
|
||||||
import static org.mockito.BDDMockito.given;
|
|
||||||
import static org.mockito.BDDMockito.then;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link DefaultCheckstyleExecutor}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
public class DefaultCheckstyleExecutorTest {
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public TemporaryFolder folder = new TemporaryFolder();
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private PluginExecutor pluginExecutor;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MavenProject mavenProject;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MavenSession mavenSession;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private ArtifactRepository artifactRepository;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private BuildPluginManager pluginManager;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Plugin rulesetPlugin;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Log log;
|
|
||||||
|
|
||||||
private DefaultCheckstyleExecutor checkstyleExecutor;
|
|
||||||
|
|
||||||
private String level;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Artifact artifact;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MavenXpp3Reader mavenXpp3Reader;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Model pomModel;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MojoExecutor.Element configElement;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MojoExecutor.Element sourceElement;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Xpp3Dom pluginConfig;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MojoExecutor.ExecutionEnvironment env;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Dependency checkstyle;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Dependency sevntu;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Dependency ruleset;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
level = "test level";
|
|
||||||
checkstyleExecutor = new DefaultCheckstyleExecutor(pluginExecutor, mavenXpp3Reader);
|
|
||||||
checkstyleExecutor.setLog(log);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void canPerformCheck()
|
|
||||||
throws MojoFailureException, MojoExecutionException, IOException, XmlPullParserException {
|
|
||||||
//given
|
|
||||||
final CheckConfiguration configuration = CheckConfiguration.builder()
|
|
||||||
.mavenProject(mavenProject)
|
|
||||||
.mavenSession(mavenSession)
|
|
||||||
.artifactRepository(artifactRepository)
|
|
||||||
.pluginManager(pluginManager)
|
|
||||||
.rulesetVersion("ruleset version")
|
|
||||||
.level(level)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
given(artifactRepository.find(any())).willReturn(artifact);
|
|
||||||
final File artifactFile = folder.newFile("pom.xml");
|
|
||||||
given(artifact.getFile()).willReturn(artifactFile);
|
|
||||||
given(mavenXpp3Reader.read(any(FileReader.class))).willReturn(pomModel);
|
|
||||||
final Properties properties = new Properties();
|
|
||||||
given(pomModel.getProperties()).willReturn(properties);
|
|
||||||
given(pluginExecutor.element(eq("configLocation"), any())).willReturn(configElement);
|
|
||||||
given(pluginExecutor.element(eq("sourceDirectory"), any())).willReturn(sourceElement);
|
|
||||||
given(pluginExecutor.configuration(configElement, sourceElement)).willReturn(pluginConfig);
|
|
||||||
given(pluginExecutor.executionEnvironment(configuration)).willReturn(env);
|
|
||||||
final List<Dependency> dependencies = new ArrayList<>();
|
|
||||||
dependencies.add(checkstyle);
|
|
||||||
dependencies.add(sevntu);
|
|
||||||
dependencies.add(ruleset);
|
|
||||||
final String pluginVersion = "plugin version";
|
|
||||||
final String checkstyleVersion = "checkstyle version";
|
|
||||||
final String sevntuVersion = "sevntu version";
|
|
||||||
final String rulesetVersion = "ruleset version";
|
|
||||||
given(pluginExecutor.dependencies(checkstyle, sevntu, ruleset)).willReturn(dependencies);
|
|
||||||
given(pluginExecutor.dependency("com.puppycrawl.tools", "checkstyle", checkstyleVersion)).willReturn(
|
|
||||||
checkstyle);
|
|
||||||
given(pluginExecutor.dependency(
|
|
||||||
"com.github.sevntu.checkstyle", "sevntu-checkstyle-maven-plugin", sevntuVersion)).willReturn(sevntu);
|
|
||||||
given(pluginExecutor.dependency("net.kemitix", "kemtiix-checkstyle-ruleset", rulesetVersion)).willReturn(
|
|
||||||
ruleset);
|
|
||||||
properties.setProperty("maven-checkstyle-plugin.version", pluginVersion);
|
|
||||||
properties.setProperty("checkstyle.version", checkstyleVersion);
|
|
||||||
properties.setProperty("sevntu.version", sevntuVersion);
|
|
||||||
given(pluginExecutor.plugin(
|
|
||||||
eq("org.apache.maven.plugins"), eq("maven-checkstyle-plugin"), eq(pluginVersion), any())).willReturn(
|
|
||||||
rulesetPlugin);
|
|
||||||
//when
|
|
||||||
checkstyleExecutor.performCheck(configuration);
|
|
||||||
//then
|
|
||||||
|
|
||||||
then(pluginExecutor).should()
|
|
||||||
.executeMojo(rulesetPlugin, "check", pluginConfig, env);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,177 +0,0 @@
|
||||||
package net.kemitix.checkstyle.ruleset.plugin;
|
|
||||||
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.model.Plugin;
|
|
||||||
import org.apache.maven.plugin.BuildPluginManager;
|
|
||||||
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
|
||||||
import org.apache.maven.plugin.PluginConfigurationException;
|
|
||||||
import org.apache.maven.plugin.PluginDescriptorParsingException;
|
|
||||||
import org.apache.maven.plugin.PluginManagerException;
|
|
||||||
import org.apache.maven.plugin.PluginNotFoundException;
|
|
||||||
import org.apache.maven.plugin.PluginResolutionException;
|
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
|
||||||
import org.apache.maven.project.MavenProject;
|
|
||||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.twdata.maven.mojoexecutor.MojoExecutor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
|
||||||
import static org.mockito.BDDMockito.given;
|
|
||||||
import static org.mockito.BDDMockito.then;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link DefaultPluginExecutor}.
|
|
||||||
*
|
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
|
||||||
*/
|
|
||||||
public class DefaultPluginExecutorTest {
|
|
||||||
|
|
||||||
private PluginExecutor pluginExecutor;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MavenProject mavenProject;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MavenSession mavenSession;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private BuildPluginManager pluginManager;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Plugin plugin;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Xpp3Dom configuration;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private PluginDescriptor pluginDescriptor;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private MojoDescriptor mojoDescriptor;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private PlexusConfiguration mojoConfiguration;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
pluginExecutor = new DefaultPluginExecutor();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void canElement() {
|
|
||||||
//when
|
|
||||||
final MojoExecutor.Element element = pluginExecutor.element("name", "value");
|
|
||||||
//then
|
|
||||||
assertThat(element.toDom()).returns("name", Xpp3Dom::getName)
|
|
||||||
.returns("value", Xpp3Dom::getValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void canConfiguration() {
|
|
||||||
//given
|
|
||||||
final MojoExecutor.Element alpha = pluginExecutor.element("alpha", "first");
|
|
||||||
final MojoExecutor.Element beta = pluginExecutor.element("beta", "second");
|
|
||||||
//when
|
|
||||||
final Xpp3Dom configuration = pluginExecutor.configuration(alpha, beta);
|
|
||||||
//then
|
|
||||||
assertThat(configuration.getChild("alpha")).returns("alpha", Xpp3Dom::getName)
|
|
||||||
.returns("first", Xpp3Dom::getValue);
|
|
||||||
assertThat(configuration.getChild("beta")).returns("beta", Xpp3Dom::getName)
|
|
||||||
.returns("second", Xpp3Dom::getValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void canExecutionEnvironment() {
|
|
||||||
//given
|
|
||||||
final CheckConfiguration configuration = createCheckConfiguration();
|
|
||||||
//when
|
|
||||||
final MojoExecutor.ExecutionEnvironment environment = pluginExecutor.executionEnvironment(configuration);
|
|
||||||
//then
|
|
||||||
assertThat(environment).returns(mavenProject, MojoExecutor.ExecutionEnvironment::getMavenProject)
|
|
||||||
.returns(mavenSession, MojoExecutor.ExecutionEnvironment::getMavenSession)
|
|
||||||
.returns(pluginManager, MojoExecutor.ExecutionEnvironment::getPluginManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CheckConfiguration createCheckConfiguration() {
|
|
||||||
return CheckConfiguration.builder()
|
|
||||||
.mavenProject(mavenProject)
|
|
||||||
.mavenSession(mavenSession)
|
|
||||||
.pluginManager(pluginManager)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void canExecuteMojo()
|
|
||||||
throws MojoExecutionException, InvalidPluginDescriptorException, PluginResolutionException,
|
|
||||||
PluginDescriptorParsingException, PluginNotFoundException, PluginManagerException,
|
|
||||||
PluginConfigurationException, MojoFailureException {
|
|
||||||
//given
|
|
||||||
final String goal = "check";
|
|
||||||
final MojoExecutor.ExecutionEnvironment environment =
|
|
||||||
pluginExecutor.executionEnvironment(createCheckConfiguration());
|
|
||||||
given(mavenSession.getCurrentProject()).willReturn(mavenProject);
|
|
||||||
given(pluginManager.loadPlugin(eq(plugin), any(), any())).willReturn(pluginDescriptor);
|
|
||||||
given(pluginDescriptor.getMojo(goal)).willReturn(mojoDescriptor);
|
|
||||||
given(mojoDescriptor.getMojoConfiguration()).willReturn(mojoConfiguration);
|
|
||||||
given(mojoConfiguration.getAttributeNames()).willReturn(new String[]{});
|
|
||||||
given(mojoConfiguration.getChildren()).willReturn(new PlexusConfiguration[]{});
|
|
||||||
//when
|
|
||||||
pluginExecutor.executeMojo(plugin, goal, configuration, environment);
|
|
||||||
//then
|
|
||||||
then(pluginManager).should()
|
|
||||||
.executeMojo(eq(mavenSession), any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void canDependency() {
|
|
||||||
//given
|
|
||||||
final String groupId = "groupId";
|
|
||||||
final String artifactId = "artifactId";
|
|
||||||
final String version = "version";
|
|
||||||
//when
|
|
||||||
final Dependency dependency = pluginExecutor.dependency(groupId, artifactId, version);
|
|
||||||
//then
|
|
||||||
assertThat(dependency).returns(groupId, Dependency::getGroupId)
|
|
||||||
.returns(artifactId, Dependency::getArtifactId)
|
|
||||||
.returns(version, Dependency::getVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void canDependencies() {
|
|
||||||
//given
|
|
||||||
final Dependency dependency = pluginExecutor.dependency("groupId", "artifactId", "version");
|
|
||||||
//when
|
|
||||||
final List<Dependency> dependencies = pluginExecutor.dependencies(dependency);
|
|
||||||
//then
|
|
||||||
assertThat(dependencies).containsExactly(dependency);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void canPlugin() {
|
|
||||||
//given
|
|
||||||
final String groupId = "groupId";
|
|
||||||
final String artifactId = "artifactId";
|
|
||||||
final String version = "version";
|
|
||||||
final List<Dependency> dependencies = pluginExecutor.dependencies(pluginExecutor.dependency("pg", "pa", "pv"));
|
|
||||||
//when
|
|
||||||
final Plugin plugin = pluginExecutor.plugin(groupId, artifactId, version, dependencies);
|
|
||||||
//then
|
|
||||||
assertThat(plugin).returns(groupId, Plugin::getGroupId)
|
|
||||||
.returns(artifactId, Plugin::getArtifactId)
|
|
||||||
.returns(version, Plugin::getVersion)
|
|
||||||
.returns(dependencies, Plugin::getDependencies);
|
|
||||||
}
|
|
||||||
}
|
|
93
pom.xml
93
pom.xml
|
@ -3,103 +3,16 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
|
||||||
<groupId>net.kemitix</groupId>
|
|
||||||
<artifactId>kemitix-parent</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
<relativePath/>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>kemitix-checkstyle-ruleset-parent</artifactId>
|
<groupId>net.kemitix.checkstyle</groupId>
|
||||||
<version>3.3.0</version>
|
<artifactId>ruleset-root</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Kemitix Checkstyle :: Ruleset :: Parent</name>
|
|
||||||
<description>Parent POM for the Kemitix Checkstyle Ruleset and it's Builder</description>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version>
|
|
||||||
<checkstyle.version>8.0</checkstyle.version>
|
|
||||||
<sevntu.version>1.24.1</sevntu.version>
|
|
||||||
|
|
||||||
<spring-platform.version>Brussels-SR3</spring-platform.version>
|
|
||||||
<spring-boot.version>1.5.4.RELEASE</spring-boot.version>
|
|
||||||
<mapstream.version>2.3.5</mapstream.version>
|
|
||||||
<map-builder.version>1.0.0</map-builder.version>
|
|
||||||
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
|
|
||||||
<immutables-value.version>2.5.6</immutables-value.version>
|
|
||||||
|
|
||||||
<mockito.version>2.8.47</mockito.version>
|
|
||||||
<assertj.version>3.8.0</assertj.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>builder</module>
|
<module>builder</module>
|
||||||
<module>ruleset</module>
|
<module>ruleset</module>
|
||||||
<module>plugin</module>
|
|
||||||
<module>regressions</module>
|
<module>regressions</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<issueManagement>
|
|
||||||
<url>https://github.com/kemitix/kemitix-checkstyle-ruleset/issues</url>
|
|
||||||
<system>GitHub Issues</system>
|
|
||||||
</issueManagement>
|
|
||||||
|
|
||||||
<scm>
|
|
||||||
<connection>scm:git:git@github.com:kemitix/kemitix-checkstyle-ruleset.git</connection>
|
|
||||||
<developerConnection>scm:git:git@github.com:kemitix/kemitix-checkstyle-ruleset.git</developerConnection>
|
|
||||||
<url>git@github.com:kemitix/kemitix-checkstyle-ruleset.git</url>
|
|
||||||
</scm>
|
|
||||||
|
|
||||||
<url>https://github.com/kemitix/kemitix-checkstyle-ruleset</url>
|
|
||||||
|
|
||||||
<inceptionYear>2016</inceptionYear>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.puppycrawl.tools</groupId>
|
|
||||||
<artifactId>checkstyle</artifactId>
|
|
||||||
<version>${checkstyle.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.sevntu-checkstyle</groupId>
|
|
||||||
<artifactId>sevntu-checks</artifactId>
|
|
||||||
<version>${sevntu.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.spring.platform</groupId>
|
|
||||||
<artifactId>platform-bom</artifactId>
|
|
||||||
<version>${spring-platform.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.speedment.common</groupId>
|
|
||||||
<artifactId>mapstream</artifactId>
|
|
||||||
<version>${mapstream.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-core</artifactId>
|
|
||||||
<version>${mockito.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.assertj</groupId>
|
|
||||||
<artifactId>assertj-core</artifactId>
|
|
||||||
<version>${assertj.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.andrz</groupId>
|
|
||||||
<artifactId>map-builder</artifactId>
|
|
||||||
<version>${map-builder.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.immutables</groupId>
|
|
||||||
<artifactId>value</artifactId>
|
|
||||||
<version>${immutables-value.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -5,25 +5,49 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.kemitix</groupId>
|
<groupId>net.kemitix</groupId>
|
||||||
<artifactId>kemitix-checkstyle-ruleset-parent</artifactId>
|
<artifactId>kemitix-parent</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>5.0.3</version>
|
||||||
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>kemitix-checkstyle-ruleset-regressions</artifactId>
|
<groupId>net.kemitix.checkstyle</groupId>
|
||||||
<name>Kemitix Checkstyle :: Ruleset :: Regression Tests</name>
|
<artifactId>ruleset-regressions</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<kemitix-checkstyle-ruleset.version>${project.version}</kemitix-checkstyle-ruleset.version>
|
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
||||||
<kemitix-checkstyle-ruleset.level>5-complexity</kemitix-checkstyle-ruleset.level>
|
<kemitix-tiles.version>0.2.0</kemitix-tiles.version>
|
||||||
|
|
||||||
|
<!-- use the disabled ruleset for normal builds. comment out the following line to check that conditions are caught -->
|
||||||
|
<ruleset.level>0-disabled</ruleset.level>
|
||||||
|
<digraph-dependency.basePackage>net.kemitix.checkstyle.regressions</digraph-dependency.basePackage>
|
||||||
<pitest.skip>true</pitest.skip>
|
<pitest.skip>true</pitest.skip>
|
||||||
|
<immutables-value.version>2.5.6</immutables-value.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.immutables</groupId>
|
<groupId>org.immutables</groupId>
|
||||||
<artifactId>value</artifactId>
|
<artifactId>value</artifactId>
|
||||||
|
<version>${immutables-value.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</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:checkstyle-tile:${kemitix-tiles.version}</tile>
|
||||||
|
</tiles>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -33,7 +33,6 @@ public class AvoidDefaultSerializableInInnerClasses {
|
||||||
/**
|
/**
|
||||||
* Inner class should not use default implementations of {@code readObject()} and {@code writeObject()}.
|
* Inner class should not use default implementations of {@code readObject()} and {@code writeObject()}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("avoiddefaultserializableininnerclasses")
|
|
||||||
public class InnerClass implements Serializable {
|
public class InnerClass implements Serializable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
package net.kemitix.checkstyle.regressions;
|
package net.kemitix.checkstyle.regressions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sample class.
|
* Sample class with no checkstyle issues.
|
||||||
*
|
*
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
* @author Paul Campbell (pcampbell@kemitix.net)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,7 +31,6 @@ public class EmptyPublicCtorInClass {
|
||||||
/**
|
/**
|
||||||
* Useless empty public constructors.
|
* Useless empty public constructors.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("emptypublicctorinclass")
|
|
||||||
EmptyPublicCtorInClass() {
|
EmptyPublicCtorInClass() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,16 +37,12 @@ class ExplicitInitialization {
|
||||||
|
|
||||||
private Object validObject = new Object();
|
private Object validObject = new Object();
|
||||||
|
|
||||||
@SuppressWarnings("explicitinitialization")
|
|
||||||
private Boolean invalidBoolean = null;
|
private Boolean invalidBoolean = null;
|
||||||
|
|
||||||
@SuppressWarnings("explicitinitialization")
|
|
||||||
private Integer invalidInteger = null;
|
private Integer invalidInteger = null;
|
||||||
|
|
||||||
@SuppressWarnings("explicitinitialization")
|
|
||||||
private String invalidString = null;
|
private String invalidString = null;
|
||||||
|
|
||||||
@SuppressWarnings("explicitinitialization")
|
|
||||||
private Object invalidObject = null;
|
private Object invalidObject = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ class FinalizeImplementation {
|
||||||
/**
|
/**
|
||||||
* Negates effect of superclass finalize.
|
* Negates effect of superclass finalize.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"PMD.EmptyFinalizer", "nofinalizer", "finalizeimplementation"})
|
@SuppressWarnings("PMD.EmptyFinalizer")
|
||||||
protected void finalize() {
|
protected void finalize() {
|
||||||
// doesn't call super.finalize()
|
// doesn't call super.finalize()
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ class MoveVariableInsideIf {
|
||||||
*
|
*
|
||||||
* @return value
|
* @return value
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("movevariableinsideif")
|
|
||||||
protected String invalid() {
|
protected String invalid() {
|
||||||
String variable = input.substring(1);
|
String variable = input.substring(1);
|
||||||
if (condition) {
|
if (condition) {
|
||||||
|
|
117
ruleset/pom.xml
117
ruleset/pom.xml
|
@ -6,97 +6,62 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.kemitix</groupId>
|
<groupId>net.kemitix</groupId>
|
||||||
<artifactId>kemitix-checkstyle-ruleset-parent</artifactId>
|
<artifactId>kemitix-parent</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>5.0.3</version>
|
||||||
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>kemitix-checkstyle-ruleset</artifactId>
|
<artifactId>kemitix-checkstyle-ruleset</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Kemitix Checkstyle :: Ruleset</name>
|
<name>Kemitix Checkstyle Ruleset</name>
|
||||||
<description>Checkstyle Ruleset for use by packages derived from kemitix-parent</description>
|
<description>A Checkstyle Ruleset</description>
|
||||||
|
<url>https://github.com/kemitix/kemitix-checkstyle-ruleset</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
|
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
||||||
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
|
<kemitix-tiles.version>0.2.0</kemitix-tiles.version>
|
||||||
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
|
|
||||||
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<profiles>
|
<licenses>
|
||||||
<profile>
|
<license>
|
||||||
<id>release</id>
|
<name>The MIT License (MIT)</name>
|
||||||
|
<url>https://opensource.org/licenses/MIT</url>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<name>Paul Campbell</name>
|
||||||
|
<email>pcampbell@kemitix.net</email>
|
||||||
|
<organization>Kemitix</organization>
|
||||||
|
<organizationUrl>https://github.com/kemitix/</organizationUrl>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<connection>scm:git:git@github.com:kemitix/kemitix-checkstyle-ruleset.git</connection>
|
||||||
|
<developerConnection>scm:git:git@github.com:kemitix/kemitix-checkstyle-ruleset.git</developerConnection>
|
||||||
|
<url>git@github.com:kemitix/kemitix-checkstyle-ruleset.git</url>
|
||||||
|
</scm>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- plugin sequence: javadoc, sources, gpg, deploy -->
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>io.repaint.maven</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>tiles-maven-plugin</artifactId>
|
||||||
<version>${maven-javadoc-plugin.version}</version>
|
<version>${tiles-maven-plugin.version}</version>
|
||||||
<executions>
|
<extensions>true</extensions>
|
||||||
<execution>
|
|
||||||
<id>attach-javadocs</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin><!-- maven-javadoc-plugin -->
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>${maven-source-plugin.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-sources</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>jar-no-fork</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin><!-- maven-source-plugin -->
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
|
||||||
<version>${maven-gpg-plugin.version}</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<passphrase>${gpg.passphrase}</passphrase>
|
<tiles>
|
||||||
|
<tile>net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version}</tile>
|
||||||
|
<tile>net.kemitix.tiles:enforcer-tile:${kemitix-tiles.version}</tile>
|
||||||
|
<tile>net.kemitix.tiles:release-tile:${kemitix-tiles.version}</tile>
|
||||||
|
</tiles>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
</plugin>
|
||||||
<execution>
|
|
||||||
<id>sign-artifacts</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>sign</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin><!-- maven-gpg-plugin -->
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
|
||||||
<version>${maven-deploy-plugin.version}</version>
|
|
||||||
</plugin><!-- maven deploy-plugin -->
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile><!-- release -->
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<distributionManagement>
|
|
||||||
<snapshotRepository>
|
|
||||||
<id>sonatype-nexus-snapshots</id>
|
|
||||||
<name>Sonatype Nexus Snapshots</name>
|
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
|
||||||
</snapshotRepository>
|
|
||||||
<repository>
|
|
||||||
<id>sonatype-nexus-staging</id>
|
|
||||||
<name>Nexus Release Repository</name>
|
|
||||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
./mvnw --projects builder,plugin test jacoco:report coveralls:report
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
if [ "$TRAVIS_BRANCH" = 'master' ] && [ "$TRAVIS_PULL_REQUEST" == 'false' ]; then
|
|
||||||
echo "Preparing to deploy to nexus..."
|
|
||||||
openssl aes-256-cbc -K $encrypted_efec3258f55d_key -iv $encrypted_efec3258f55d_iv \
|
|
||||||
-in travis-ci/codesigning.asc.enc -out travis-ci/codesigning.asc -d
|
|
||||||
echo "Signing key decrypted"
|
|
||||||
gpg --batch --fast-import travis-ci/codesigning.asc
|
|
||||||
echo "Signing key imported"
|
|
||||||
./mvnw --projects .,plugin,ruleset --settings travis-ci/travis-settings.xml \
|
|
||||||
-Dskip-Tests=true -P release -B deploy
|
|
||||||
echo "Deploy complete"
|
|
||||||
else
|
|
||||||
echo "Not deploying"
|
|
||||||
echo " TRAVIS_BRANCH: $TRAVIS_BRANCH"
|
|
||||||
echo " TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST"
|
|
||||||
fi
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0">
|
|
||||||
<servers>
|
|
||||||
<server>
|
|
||||||
<id>sonatype-nexus-snapshots</id>
|
|
||||||
<username>kemitix</username>
|
|
||||||
<password>${env.CI_DEPLOY_PASSWORD}</password>
|
|
||||||
</server>
|
|
||||||
<server>
|
|
||||||
<id>sonatype-nexus-staging</id>
|
|
||||||
<username>kemitix</username>
|
|
||||||
<password>${env.CI_DEPLOY_PASSWORD}</password>
|
|
||||||
</server>
|
|
||||||
</servers>
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>gpg-sign</id>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>true</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<gpg.executable>gpg</gpg.executable>
|
|
||||||
<gpg.keyname>${env.CI_DEPLOY_GPG_KEYNAME}</gpg.keyname>
|
|
||||||
<gpg.passphrase>${env.CI_DEPLOY_GPG_PASSPHRASE}</gpg.passphrase>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
</settings>
|
|
Loading…
Reference in a new issue