Merge pull request #23 from kemitix/pmd-cleanup
Clean up to match PMD rulest
This commit is contained in:
commit
8f6776465f
10 changed files with 66 additions and 20 deletions
|
@ -15,6 +15,14 @@ pipeline {
|
||||||
error("Build failed because SNAPSHOT version")
|
error("Build failed because SNAPSHOT version")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Static Code Analysis') {
|
||||||
|
steps {
|
||||||
|
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
||||||
|
sh "${mvn} compile checkstyle:checkstyle pmd:pmd"
|
||||||
|
}
|
||||||
|
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
parallel {
|
parallel {
|
||||||
stage('Java 8') {
|
stage('Java 8') {
|
||||||
|
@ -51,15 +59,10 @@ pipeline {
|
||||||
archiveArtifacts '**/target/*.jar'
|
archiveArtifacts '**/target/*.jar'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Quality') {
|
|
||||||
steps {
|
|
||||||
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
when { expression { (env.GIT_BRANCH == 'master') } }
|
when { expression { (env.GIT_BRANCH == 'master') } }
|
||||||
steps {
|
steps {
|
||||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') {
|
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
||||||
sh "${mvn} deploy --activate-profiles release -DskipTests=true"
|
sh "${mvn} deploy --activate-profiles release -DskipTests=true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -16,7 +16,7 @@
|
||||||
<assertj.version>3.9.1</assertj.version>
|
<assertj.version>3.9.1</assertj.version>
|
||||||
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
|
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
|
||||||
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
|
||||||
<kemitix-tiles.version>0.6.1</kemitix-tiles.version>
|
<kemitix-tiles.version>0.7.1</kemitix-tiles.version>
|
||||||
<maven-surefire-plugin.version>2.20.1</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.20.1</maven-surefire-plugin.version>
|
||||||
<maven-failsafe-plugin.version>2.20.1</maven-failsafe-plugin.version>
|
<maven-failsafe-plugin.version>2.20.1</maven-failsafe-plugin.version>
|
||||||
<lombok.version>1.16.20</lombok.version>
|
<lombok.version>1.16.20</lombok.version>
|
||||||
|
|
36
src/main/java/net/kemitix/conditional/Action.java
Normal file
36
src/main/java/net/kemitix/conditional/Action.java
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
* 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.conditional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An action to perform in a clause when a {@link Condition} is met.
|
||||||
|
*
|
||||||
|
* @author Paul Campbell (pcampbell@kemitix.net)
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Action {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The action to perform.
|
||||||
|
*/
|
||||||
|
void perform();
|
||||||
|
}
|
|
@ -78,6 +78,7 @@ public interface Condition {
|
||||||
*
|
*
|
||||||
* @return the Condition
|
* @return the Condition
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.ShortMethodName")
|
||||||
Condition or(boolean clause);
|
Condition or(boolean clause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,14 +99,14 @@ public interface Condition {
|
||||||
*
|
*
|
||||||
* @return the Condition
|
* @return the Condition
|
||||||
*/
|
*/
|
||||||
Condition then(Runnable response);
|
Condition then(Action response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform this response if the {@code Condition} is {@code false}.
|
* Perform this response if the {@code Condition} is {@code false}.
|
||||||
*
|
*
|
||||||
* @param response the response to perform
|
* @param response the response to perform
|
||||||
*/
|
*/
|
||||||
void otherwise(Runnable response);
|
void otherwise(Action response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@code Condition} for the clause as a continuation to an existing {@code Condition}.
|
* Create a new {@code Condition} for the clause as a continuation to an existing {@code Condition}.
|
||||||
|
|
|
@ -28,7 +28,7 @@ package net.kemitix.conditional;
|
||||||
*/
|
*/
|
||||||
final class FalseCondition implements Condition {
|
final class FalseCondition implements Condition {
|
||||||
|
|
||||||
protected static final Condition FALSE = new net.kemitix.conditional.FalseCondition();
|
public static final Condition FALSE = new net.kemitix.conditional.FalseCondition();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Condition and(final boolean clause) {
|
public Condition and(final boolean clause) {
|
||||||
|
@ -36,18 +36,19 @@ final class FalseCondition implements Condition {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("PMD.ShortMethodName")
|
||||||
public Condition or(final boolean secondClause) {
|
public Condition or(final boolean secondClause) {
|
||||||
return Condition.where(secondClause);
|
return Condition.where(secondClause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Condition then(final Runnable response) {
|
public Condition then(final Action response) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void otherwise(final Runnable response) {
|
public void otherwise(final Action response) {
|
||||||
response.run();
|
response.perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ class FalseValueClause<T> implements Value.ValueClause<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("PMD.ShortMethodName")
|
||||||
public Value.ValueClause<T> or(final boolean clause) {
|
public Value.ValueClause<T> or(final boolean clause) {
|
||||||
return Value.where(clause);
|
return Value.where(clause);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ package net.kemitix.conditional;
|
||||||
*/
|
*/
|
||||||
final class TrueCondition implements Condition {
|
final class TrueCondition implements Condition {
|
||||||
|
|
||||||
protected static final Condition TRUE = new net.kemitix.conditional.TrueCondition();
|
public static final Condition TRUE = new net.kemitix.conditional.TrueCondition();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Condition and(final boolean clause) {
|
public Condition and(final boolean clause) {
|
||||||
|
@ -36,18 +36,19 @@ final class TrueCondition implements Condition {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("PMD.ShortMethodName")
|
||||||
public Condition or(final boolean secondClause) {
|
public Condition or(final boolean secondClause) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Condition then(final Runnable response) {
|
public Condition then(final Action response) {
|
||||||
response.run();
|
response.perform();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void otherwise(final Runnable response) {
|
public void otherwise(final Action response) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ class TrueValueClause<T> implements Value.ValueClause<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("PMD.ShortMethodName")
|
||||||
public Value.ValueClause<T> or(final boolean clause) {
|
public Value.ValueClause<T> or(final boolean clause) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +58,7 @@ class TrueValueClause<T> implements Value.ValueClause<T> {
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
private class TrueValueSupplier implements ValueSupplier<T> {
|
private class TrueValueSupplier implements ValueSupplier<T> {
|
||||||
|
|
||||||
private final Supplier<T> valueSupplier;
|
private final transient Supplier<T> valueSupplier;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T otherwise(final Supplier<T> falseSupplier) {
|
public T otherwise(final Supplier<T> falseSupplier) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ public interface Value {
|
||||||
*
|
*
|
||||||
* @return the value from either the trueSupplier or the falseSupplier
|
* @return the value from either the trueSupplier or the falseSupplier
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.LawOfDemeter")
|
||||||
static <T> T where(
|
static <T> T where(
|
||||||
boolean clause,
|
boolean clause,
|
||||||
Supplier<T> trueSupplier,
|
Supplier<T> trueSupplier,
|
||||||
|
@ -123,6 +124,7 @@ public interface Value {
|
||||||
*
|
*
|
||||||
* @return a true or false value clause
|
* @return a true or false value clause
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.ShortMethodName")
|
||||||
ValueClause<T> or(boolean clause);
|
ValueClause<T> or(boolean clause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,9 +10,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*/
|
*/
|
||||||
public class ConditionalTest {
|
public class ConditionalTest {
|
||||||
|
|
||||||
private Runnable thenResponse;
|
private Action thenResponse;
|
||||||
|
|
||||||
private Runnable otherwiseResponse;
|
private Action otherwiseResponse;
|
||||||
|
|
||||||
private boolean thenFlag;
|
private boolean thenFlag;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue