Skip to content

Commit 637d96d

Browse files
committed
Fix some quality fixes
1 parent 0039e6b commit 637d96d

File tree

5 files changed

+39
-31
lines changed

5 files changed

+39
-31
lines changed

checkstyle.xml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
<property name="eachLine" value="true"/>
2424
</module>
2525

26+
<module name="LineLength">
27+
<property name="max" value="120"/>
28+
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
29+
</module>
30+
2631
<module name="TreeWalker">
2732
<module name="OuterTypeFilename"/>
2833
<module name="IllegalTokenText">
@@ -37,10 +42,6 @@
3742
<property name="allowByTailComment" value="true"/>
3843
<property name="allowNonPrintableEscapes" value="true"/>
3944
</module>
40-
<module name="LineLength">
41-
<property name="max" value="120"/>
42-
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
43-
</module>
4445
<module name="AvoidStarImport"/>
4546
<module name="OneTopLevelClass"/>
4647
<module name="NoLineWrap"/>
@@ -205,24 +206,22 @@
205206
</module>
206207
<module name="NonEmptyAtclauseDescription"/>
207208
<module name="JavadocTagContinuationIndentation"/>
208-
<!--<module name="SummaryJavadoc">-->
209-
<!--<property name="forbiddenSummaryFragments"-->
210-
<!--value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>-->
211-
<!--</module>-->
209+
<module name="SummaryJavadoc">
210+
<property name="forbiddenSummaryFragments"
211+
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
212+
</module>
212213
<module name="JavadocParagraph"/>
213214
<module name="AtclauseOrder">
214215
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
215216
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
216217
</module>
217-
<module name="JavadocMethod">
218-
<property name="scope" value="public"/>
219-
<property name="allowMissingParamTags" value="true"/>
220-
<property name="allowMissingThrowsTags" value="true"/>
221-
<property name="allowMissingReturnTag" value="true"/>
218+
<module name="MissingJavadocMethodCheck">
222219
<property name="allowMissingPropertyJavadoc" value="true"/>
223220
<property name="minLineCount" value="2"/>
221+
</module>
222+
<module name="JavadocMethod">
223+
<property name="scope" value="public"/>
224224
<property name="allowedAnnotations" value="Override, Test"/>
225-
<property name="allowThrowsTagsForSubclasses" value="true"/>
226225
</module>
227226
<module name="MethodName">
228227
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>

core/src/main/java/org/seedstack/seed/core/Seed.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import com.google.common.base.Strings;
1212
import com.google.common.collect.Lists;
13+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
1314
import io.nuun.kernel.api.Kernel;
1415
import io.nuun.kernel.api.config.KernelConfiguration;
1516
import org.fusesource.jansi.Ansi;
@@ -191,6 +192,7 @@ static void markLifecycleExceptionHandlerEnabled() {
191192
*
192193
* @param args The launch arguments.
193194
*/
195+
@SuppressFBWarnings(value = "DM_EXIT", justification = "This is the entry point of the framework, to be used from main methods")
194196
public static void launch(String[] args) {
195197
try {
196198
final SeedLauncher seedLauncher;

core/src/main/java/org/seedstack/seed/core/internal/CoreModule.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,19 @@ protected void configure() {
4242
}
4343

4444
private <T> Matcher<T> createMatcherFromPredicate(Predicate<T> predicate) {
45-
return new AbstractMatcher<T>() {
46-
@Override
47-
public boolean matches(T t) {
48-
return predicate.test(t);
49-
}
50-
};
45+
return new PredicateToMatcher<>(predicate);
46+
}
47+
48+
private static class PredicateToMatcher<T> extends AbstractMatcher<T> {
49+
private final Predicate<T> predicate;
50+
51+
public PredicateToMatcher(Predicate<T> predicate) {
52+
this.predicate = predicate;
53+
}
54+
55+
@Override
56+
public boolean matches(T t) {
57+
return predicate.test(t);
58+
}
5159
}
5260
}

core/src/main/java/org/seedstack/seed/core/internal/configuration/AvailablePortFunctionHolder.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,21 @@ public class AvailablePortFunctionHolder implements ConfigFunctionHolder {
2727
@ConfigFunction
2828
int availableTcpPort(String name) {
2929
return TCP_PORTS.computeIfAbsent(name, n -> {
30-
synchronized (TCP_PORTS) {
31-
for (int i = PORT_RANGE_MIN; i <= PORT_RANGE_MAX; i++) {
32-
if (isTcpPortAvailable(i)) {
33-
return i;
34-
}
30+
for (int i = PORT_RANGE_MIN; i <= PORT_RANGE_MAX; i++) {
31+
if (isTcpPortAvailable(i)) {
32+
return i;
3533
}
36-
throw new IllegalStateException("Unable to find an available TCP port in range " + PORT_RANGE_MIN + "-" + PORT_RANGE_MAX);
3734
}
35+
throw new IllegalStateException("Unable to find an available TCP port in range " + PORT_RANGE_MIN + "-" + PORT_RANGE_MAX);
3836
});
3937
}
4038

4139
@ConfigFunction
4240
int availableUdpPort(String name) {
4341
return UDP_PORTS.computeIfAbsent(name, n -> {
44-
synchronized (UDP_PORTS) {
45-
for (int i = PORT_RANGE_MIN; i <= PORT_RANGE_MAX; i++) {
46-
if (isUdpPortAvailable(i)) {
47-
return i;
48-
}
42+
for (int i = PORT_RANGE_MIN; i <= PORT_RANGE_MAX; i++) {
43+
if (isUdpPortAvailable(i)) {
44+
return i;
4945
}
5046
}
5147
throw new IllegalStateException("Unable to find an available UDP port in range " + PORT_RANGE_MIN + "-" + PORT_RANGE_MAX);

specs/src/main/java/org/seedstack/seed/ClassConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
package org.seedstack.seed;
99

10+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11+
1012
import java.util.*;
1113
import java.util.function.BiConsumer;
1214

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

0 commit comments

Comments
 (0)