Skip to content

Commit

Permalink
Tidying. Replace findbugs with spotbugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pholser committed Nov 21, 2020
1 parent 4b56e0f commit 440a2c8
Show file tree
Hide file tree
Showing 25 changed files with 121 additions and 68 deletions.
4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
<artifactId>maven-pmd-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Expand Down
4 changes: 2 additions & 2 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
<artifactId>maven-pmd-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Expand Down
4 changes: 2 additions & 2 deletions generators/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
<artifactId>maven-pmd-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>eu.somatik.serviceloader-maven-plugin</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ a copy of this software and associated documentation files (the
* Produces values of type {@link OptionalDouble}.
*/
public class OptionalDoubleGenerator extends Generator<OptionalDouble> {
private final DoubleGenerator doubleGenerator = new DoubleGenerator();
private final DoubleGenerator doubles = new DoubleGenerator();

public OptionalDoubleGenerator() {
super(OptionalDouble.class);
Expand All @@ -60,14 +60,17 @@ public OptionalDoubleGenerator() {
* @param range annotation that gives the range's constraints
*/
public void configure(InRange range) {
doubleGenerator.configure(range);
doubles.configure(range);
}

@Override public OptionalDouble generate(SourceOfRandomness random, GenerationStatus status) {
@Override public OptionalDouble generate(
SourceOfRandomness random,
GenerationStatus status) {

double trial = random.nextDouble();
return trial < 0.25
? OptionalDouble.empty()
: OptionalDouble.of(doubleGenerator.generate(random, status));
: OptionalDouble.of(doubles.generate(random, status));
}

@Override public List<OptionalDouble> doShrink(
Expand All @@ -80,7 +83,7 @@ public void configure(InRange range) {
List<OptionalDouble> shrinks = new ArrayList<>();
shrinks.add(OptionalDouble.empty());
shrinks.addAll(
doubleGenerator.shrink(random, larger.getAsDouble())
doubles.shrink(random, larger.getAsDouble())
.stream()
.map(OptionalDouble::of)
.collect(toList()));
Expand All @@ -91,7 +94,7 @@ public void configure(InRange range) {
OptionalDouble narrowed = narrow(value);

return narrowed.isPresent()
? doubleGenerator.magnitude(narrowed.getAsDouble())
? doubles.magnitude(narrowed.getAsDouble())
: ZERO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ a copy of this software and associated documentation files (the
* Produces values of type {@link OptionalInt}.
*/
public class OptionalIntGenerator extends Generator<OptionalInt> {
private final IntegerGenerator integerGenerator = new IntegerGenerator();
private final IntegerGenerator integers = new IntegerGenerator();

public OptionalIntGenerator() {
super(OptionalInt.class);
Expand All @@ -59,7 +59,7 @@ public OptionalIntGenerator() {
* @param range annotation that gives the range's constraints
*/
public void configure(InRange range) {
integerGenerator.configure(range);
integers.configure(range);
}

@Override public OptionalInt generate(
Expand All @@ -69,7 +69,7 @@ public void configure(InRange range) {
double trial = random.nextDouble();
return trial < 0.25
? OptionalInt.empty()
: OptionalInt.of(integerGenerator.generate(random, status));
: OptionalInt.of(integers.generate(random, status));
}

@Override public List<OptionalInt> doShrink(
Expand All @@ -82,7 +82,7 @@ public void configure(InRange range) {
List<OptionalInt> shrinks = new ArrayList<>();
shrinks.add(OptionalInt.empty());
shrinks.addAll(
integerGenerator.shrink(random, larger.getAsInt())
integers.shrink(random, larger.getAsInt())
.stream()
.map(OptionalInt::of)
.collect(toList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ a copy of this software and associated documentation files (the
* Produces values of type {@link OptionalLong}.
*/
public class OptionalLongGenerator extends Generator<OptionalLong> {
private final LongGenerator longGenerator = new LongGenerator();
private final LongGenerator longs = new LongGenerator();

public OptionalLongGenerator() {
super(OptionalLong.class);
Expand All @@ -59,7 +59,7 @@ public OptionalLongGenerator() {
* @param range annotation that gives the range's constraints
*/
public void configure(InRange range) {
longGenerator.configure(range);
longs.configure(range);
}

@Override public OptionalLong generate(
Expand All @@ -69,7 +69,7 @@ public void configure(InRange range) {
double trial = random.nextDouble();
return trial < 0.25
? OptionalLong.empty()
: OptionalLong.of(longGenerator.generate(random, status));
: OptionalLong.of(longs.generate(random, status));
}

@Override public List<OptionalLong> doShrink(
Expand All @@ -82,7 +82,7 @@ public void configure(InRange range) {
List<OptionalLong> shrinks = new ArrayList<>();
shrinks.add(OptionalLong.empty());
shrinks.addAll(
longGenerator.shrink(random, larger.getAsLong())
longs.shrink(random, larger.getAsLong())
.stream()
.map(OptionalLong::of)
.collect(toList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected final UUID newUUID(byte[] bytes) {
private abstract static class NameBasedUUIDGenerator
extends AbstractUUIDGenerator {

private final StringGenerator stringGenerator = new StringGenerator();
private final StringGenerator strings = new StringGenerator();
private final int versionMask;
private final MessageDigest digest;
private Namespace namespace;
Expand All @@ -99,10 +99,11 @@ protected NameBasedUUIDGenerator(

digest.reset();

Namespaces namespaces = namespace == null ? URL : namespace.value();
Namespaces namespaces =
namespace == null ? URL : namespace.value();
digest.update(namespaces.bytes);
digest.update(
stringGenerator.generate(random, status)
strings.generate(random, status)
.getBytes(StandardCharsets.UTF_8));

byte[] hash = digest.digest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ a copy of this software and associated documentation files (the
*
* @param <T> the type of set generated
*/
public abstract class SetGenerator<T extends Set> extends CollectionGenerator<T> {
public abstract class SetGenerator<T extends Set>
extends CollectionGenerator<T> {

protected SetGenerator(Class<T> type) {
super(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ public CallableGenerator() {
}

@SuppressWarnings("unchecked")
@Override public Callable<V> generate(SourceOfRandomness random, GenerationStatus status) {
return makeLambda(Callable.class, componentGenerators().get(0), status);
@Override public Callable<V> generate(
SourceOfRandomness random,
GenerationStatus status) {

return makeLambda(
Callable.class,
componentGenerators().get(0),
status);
}

@Override public int numberOfNeededComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public BiPredicateGenerator() {
super(BiPredicate.class);
}

@Override
public void provide(Generators provided) {
@Override public void provide(Generators provided) {
super.provide(provided);

generator = gen().type(boolean.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ a copy of this software and associated documentation files (the
*
* @param <T> parameters type and return type of produced operator
*/
public class BinaryOperatorGenerator<T> extends ComponentizedGenerator<BinaryOperator> {
public class BinaryOperatorGenerator<T>
extends ComponentizedGenerator<BinaryOperator> {

public BinaryOperatorGenerator() {
super(BinaryOperator.class);
}

@SuppressWarnings("unchecked")
@Override public BinaryOperator<T> generate(SourceOfRandomness random, GenerationStatus status) {
return makeLambda(BinaryOperator.class, componentGenerators().get(0), status);
@Override public BinaryOperator<T> generate(
SourceOfRandomness random,
GenerationStatus status) {

return makeLambda(
BinaryOperator.class,
componentGenerators().get(0),
status);
}

@Override public int numberOfNeededComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ a copy of this software and associated documentation files (the
*
* @param <R> return type of produced function
*/
public class DoubleFunctionGenerator<R> extends ComponentizedGenerator<DoubleFunction> {
public class DoubleFunctionGenerator<R>
extends ComponentizedGenerator<DoubleFunction> {

public DoubleFunctionGenerator() {
super(DoubleFunction.class);
}

@SuppressWarnings("unchecked")
@Override public DoubleFunction<R> generate(SourceOfRandomness random, GenerationStatus status) {
return makeLambda(DoubleFunction.class, componentGenerators().get(0), status);
@Override public DoubleFunction<R> generate(
SourceOfRandomness random,
GenerationStatus status) {

return makeLambda(
DoubleFunction.class,
componentGenerators().get(0),
status);
}

@Override public int numberOfNeededComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ public FunctionGenerator() {
}

@SuppressWarnings("unchecked")
@Override public Function<T, R> generate(SourceOfRandomness random, GenerationStatus status) {
return makeLambda(Function.class, componentGenerators().get(1), status);
@Override public Function<T, R> generate(
SourceOfRandomness random,
GenerationStatus status) {

return makeLambda(
Function.class,
componentGenerators().get(1),
status);
}

@Override public int numberOfNeededComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ a copy of this software and associated documentation files (the
*
* @param <R> return type of produced function
*/
public class IntFunctionGenerator<R> extends ComponentizedGenerator<IntFunction> {
public class IntFunctionGenerator<R>
extends ComponentizedGenerator<IntFunction> {

public IntFunctionGenerator() {
super(IntFunction.class);
}

@SuppressWarnings("unchecked")
@Override public IntFunction<R> generate(SourceOfRandomness random, GenerationStatus status) {
return makeLambda(IntFunction.class, componentGenerators().get(0), status);
@Override public IntFunction<R> generate(
SourceOfRandomness random,
GenerationStatus status) {

return makeLambda(
IntFunction.class,
componentGenerators().get(0),
status);
}

@Override public int numberOfNeededComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ a copy of this software and associated documentation files (the
*
* @param <R> return type of produced function
*/
public class LongFunctionGenerator<R> extends ComponentizedGenerator<LongFunction> {
public class LongFunctionGenerator<R>
extends ComponentizedGenerator<LongFunction> {

public LongFunctionGenerator() {
super(LongFunction.class);
}

@SuppressWarnings("unchecked")
@Override public LongFunction<R> generate(SourceOfRandomness random, GenerationStatus status) {
return makeLambda(LongFunction.class, componentGenerators().get(0), status);
@Override public LongFunction<R> generate(
SourceOfRandomness random,
GenerationStatus status) {

return makeLambda(
LongFunction.class,
componentGenerators().get(0),
status);
}

@Override public int numberOfNeededComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public PredicateGenerator() {
super(Predicate.class);
}

@Override
public void provide(Generators provided) {
@Override public void provide(Generators provided) {
super.provide(provided);

generator = gen().type(boolean.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ public SupplierGenerator() {
}

@SuppressWarnings("unchecked")
@Override public Supplier<T> generate(SourceOfRandomness random, GenerationStatus status) {
return makeLambda(Supplier.class, componentGenerators().get(0), status);
@Override public Supplier<T> generate(
SourceOfRandomness random,
GenerationStatus status) {

return makeLambda(
Supplier.class,
componentGenerators().get(0),
status);
}

@Override public int numberOfNeededComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public ToDoubleBiFunctionGenerator() {
super(ToDoubleBiFunction.class);
}

@Override
public void provide(Generators provided) {
@Override public void provide(Generators provided) {
super.provide(provided);

generator = gen().type(double.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public ToDoubleFunctionGenerator() {
super(ToDoubleFunction.class);
}

@Override
public void provide(Generators provided) {
@Override public void provide(Generators provided) {
super.provide(provided);

generator = gen().type(double.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public ToIntBiFunctionGenerator() {
super(ToIntBiFunction.class);
}

@Override
public void provide(Generators provided) {
@Override public void provide(Generators provided) {
super.provide(provided);

generator = gen().type(int.class);
Expand Down

0 comments on commit 440a2c8

Please sign in to comment.