Skip to content

Commit

Permalink
Fix some quality fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienlauer committed Jul 1, 2021
1 parent 0039e6b commit 637d96d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 31 deletions.
27 changes: 13 additions & 14 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<property name="eachLine" value="true"/>
</module>

<module name="LineLength">
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<module name="TreeWalker">
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
Expand All @@ -37,10 +42,6 @@
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="LineLength">
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="AvoidStarImport"/>
<module name="OneTopLevelClass"/>
<module name="NoLineWrap"/>
Expand Down Expand Up @@ -205,24 +206,22 @@
</module>
<module name="NonEmptyAtclauseDescription"/>
<module name="JavadocTagContinuationIndentation"/>
<!--<module name="SummaryJavadoc">-->
<!--<property name="forbiddenSummaryFragments"-->
<!--value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>-->
<!--</module>-->
<module name="SummaryJavadoc">
<property name="forbiddenSummaryFragments"
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
</module>
<module name="JavadocParagraph"/>
<module name="AtclauseOrder">
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<module name="MissingJavadocMethodCheck">
<property name="allowMissingPropertyJavadoc" value="true"/>
<property name="minLineCount" value="2"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
</module>
<module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/seedstack/seed/core/Seed.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.nuun.kernel.api.Kernel;
import io.nuun.kernel.api.config.KernelConfiguration;
import org.fusesource.jansi.Ansi;
Expand Down Expand Up @@ -191,6 +192,7 @@ static void markLifecycleExceptionHandlerEnabled() {
*
* @param args The launch arguments.
*/
@SuppressFBWarnings(value = "DM_EXIT", justification = "This is the entry point of the framework, to be used from main methods")
public static void launch(String[] args) {
try {
final SeedLauncher seedLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,19 @@ protected void configure() {
}

private <T> Matcher<T> createMatcherFromPredicate(Predicate<T> predicate) {
return new AbstractMatcher<T>() {
@Override
public boolean matches(T t) {
return predicate.test(t);
}
};
return new PredicateToMatcher<>(predicate);
}

private static class PredicateToMatcher<T> extends AbstractMatcher<T> {
private final Predicate<T> predicate;

public PredicateToMatcher(Predicate<T> predicate) {
this.predicate = predicate;
}

@Override
public boolean matches(T t) {
return predicate.test(t);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,21 @@ public class AvailablePortFunctionHolder implements ConfigFunctionHolder {
@ConfigFunction
int availableTcpPort(String name) {
return TCP_PORTS.computeIfAbsent(name, n -> {
synchronized (TCP_PORTS) {
for (int i = PORT_RANGE_MIN; i <= PORT_RANGE_MAX; i++) {
if (isTcpPortAvailable(i)) {
return i;
}
for (int i = PORT_RANGE_MIN; i <= PORT_RANGE_MAX; i++) {
if (isTcpPortAvailable(i)) {
return i;
}
throw new IllegalStateException("Unable to find an available TCP port in range " + PORT_RANGE_MIN + "-" + PORT_RANGE_MAX);
}
throw new IllegalStateException("Unable to find an available TCP port in range " + PORT_RANGE_MIN + "-" + PORT_RANGE_MAX);
});
}

@ConfigFunction
int availableUdpPort(String name) {
return UDP_PORTS.computeIfAbsent(name, n -> {
synchronized (UDP_PORTS) {
for (int i = PORT_RANGE_MIN; i <= PORT_RANGE_MAX; i++) {
if (isUdpPortAvailable(i)) {
return i;
}
for (int i = PORT_RANGE_MIN; i <= PORT_RANGE_MAX; i++) {
if (isUdpPortAvailable(i)) {
return i;
}
}
throw new IllegalStateException("Unable to find an available UDP port in range " + PORT_RANGE_MIN + "-" + PORT_RANGE_MAX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
package org.seedstack.seed;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import java.util.*;
import java.util.function.BiConsumer;

Expand Down Expand Up @@ -112,6 +114,7 @@ public String get(String key) {
* @param key the key to retrieve the value of.
* @return the split value or null.
*/
@SuppressFBWarnings(value = "PZLA_PREFER_ZERO_LENGTH_ARRAYS", justification = "Null value denotes absence of key which is a valid use case")
public String[] getArray(String key) {
String s = map.get(key);
if (s == null) {
Expand Down

0 comments on commit 637d96d

Please sign in to comment.