Skip to content

Commit

Permalink
Don't initialize an instance variable to its default value
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Oct 27, 2023
1 parent 5433084 commit fccb6fc
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 67 deletions.
1 change: 1 addition & 0 deletions src/conf/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ limitations under the License.
<property name="headerFile" value="${checkstyle.header.file}"/>
</module>
<module name="TreeWalker">
<module name="ExplicitInitializationCheck" />
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* execute the @code{text} with a zero value for each remaining @{code idx} value.
*/
class CountingLongPredicate implements LongPredicate {
private int idx = 0;
private int idx;
private final long[] ary;
private final LongBiPredicate func;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static IndexProducer fromBitMapProducer(final BitMapProducer producer) {
Objects.requireNonNull(producer, "producer");
return consumer -> {
final LongPredicate longPredicate = new LongPredicate() {
int wordIdx = 0;
int wordIdx;

@Override
public boolean test(long word) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ClosureUtilsTest {
private static final Object cString = "Hello";

static class MockClosure<T> implements Closure<T> {
int count = 0;
int count;

@Override
public void execute(final T object) {
Expand All @@ -58,7 +58,7 @@ public void reset() {
}

static class MockTransformer<T> implements Transformer<T, T> {
int count = 0;
int count;

@Override
public T transform(final T object) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,54 +69,54 @@ public class CollectionUtilsTest extends MockTestCase {
/**
* Collection of {@link Integer}s
*/
private List<Integer> collectionA = null;
private List<Integer> collectionA;

/**
* Collection of {@link Long}s
*/
private List<Long> collectionB = null;
private List<Long> collectionB;

/**
* Collection of {@link Integer}s that are equivalent to the Longs in
* collectionB.
*/
private Collection<Integer> collectionC = null;
private Collection<Integer> collectionC;

/**
* Sorted Collection of {@link Integer}s
*/
private Collection<Integer> collectionD = null;
private Collection<Integer> collectionD;

/**
* Sorted Collection of {@link Integer}s
*/
private Collection<Integer> collectionE = null;
private Collection<Integer> collectionE;

/**
* Collection of {@link Integer}s, bound as {@link Number}s
*/
private Collection<Number> collectionA2 = null;
private Collection<Number> collectionA2;

/**
* Collection of {@link Long}s, bound as {@link Number}s
*/
private Collection<Number> collectionB2 = null;
private Collection<Number> collectionB2;

/**
* Collection of {@link Integer}s (cast as {@link Number}s) that are
* equivalent to the Longs in collectionB.
*/
private Collection<Number> collectionC2 = null;
private Collection<Number> collectionC2;

private Iterable<Integer> iterableA = null;
private Iterable<Integer> iterableA;

private Iterable<Long> iterableB = null;
private Iterable<Long> iterableB;

private Iterable<Integer> iterableC = null;
private Iterable<Integer> iterableC;

private Iterable<Number> iterableA2 = null;
private Iterable<Number> iterableA2;

private Iterable<Number> iterableB2 = null;
private Iterable<Number> iterableB2;

private final Collection<Integer> emptyCollection = new ArrayList<>(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public int hashCode() { // please Findbugs
}

public static class Mock3 {
private static int cCounter = 0;
private static int cCounter;
private final int iVal;
public Mock3() {
iVal = cCounter++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,27 @@ public class FluentIterableTest {
/**
* Iterable of {@link Integer}s
*/
private Iterable<Integer> iterableA = null;
private Iterable<Integer> iterableA;

/**
* Iterable of {@link Long}s
*/
private Iterable<Long> iterableB = null;
private Iterable<Long> iterableB;

/**
* Collection of even {@link Integer}s
*/
private Iterable<Integer> iterableEven = null;
private Iterable<Integer> iterableEven;

/**
* Collection of odd {@link Integer}s
*/
private Iterable<Integer> iterableOdd = null;
private Iterable<Integer> iterableOdd;

/**
* An empty Iterable.
*/
private Iterable<Integer> emptyIterable = null;
private Iterable<Integer> emptyIterable;

@BeforeEach
public void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ public class IterableUtilsTest {
/**
* Iterable of {@link Integer}s
*/
private Iterable<Integer> iterableA = null;
private Iterable<Integer> iterableA;

/**
* Iterable of {@link Long}s
*/
private Iterable<Long> iterableB = null;
private Iterable<Long> iterableB;

/**
* An empty Iterable.
*/
private Iterable<Integer> emptyIterable = null;
private Iterable<Integer> emptyIterable;

@BeforeEach
public void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ public class IteratorUtilsTest {
/**
* Collection of {@link Integer}s
*/
private List<Integer> collectionA = null;
private List<Integer> collectionA;

/**
* Collection of even {@link Integer}s
*/
private List<Integer> collectionEven = null;
private List<Integer> collectionEven;

/**
* Collection of odd {@link Integer}s
*/
private List<Integer> collectionOdd = null;
private List<Integer> collectionOdd;

private final Collection<Integer> emptyCollection = new ArrayList<>(1);

private Iterable<Integer> iterableA = null;
private Iterable<Integer> iterableA;

/**
* Creates a NodeList containing the specified nodes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public boolean isSetValueSupported() {
*/
private static final class TestOrderedBidiMap<K, V> extends AbstractOrderedBidiMapDecorator<K, V> {

private TestOrderedBidiMap<V, K> inverse = null;
private TestOrderedBidiMap<V, K> inverse;

TestOrderedBidiMap() {
super(new DualTreeBidiMap<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public CollatingIteratorTest() {

//--------------------------------------------------------------- Lifecycle

private Comparator<Integer> comparator = null;
private ArrayList<Integer> evens = null;
private ArrayList<Integer> odds = null;
private ArrayList<Integer> fib = null;
private Comparator<Integer> comparator;
private ArrayList<Integer> evens;
private ArrayList<Integer> odds;
private ArrayList<Integer> fib;

@BeforeEach
public void setUp() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@
@SuppressWarnings("boxing")
public class FilterListIteratorTest {

private ArrayList<Integer> list = null;
private ArrayList<Integer> odds = null;
private ArrayList<Integer> evens = null;
private ArrayList<Integer> threes = null;
private ArrayList<Integer> fours = null;
private ArrayList<Integer> sixes = null;
private Predicate<Integer> truePred = null;
private Predicate<Integer> falsePred = null;
private Predicate<Integer> evenPred = null;
private Predicate<Integer> oddPred = null;
private Predicate<Integer> threePred = null;
private Predicate<Integer> fourPred = null;
private ArrayList<Integer> list;
private ArrayList<Integer> odds;
private ArrayList<Integer> evens;
private ArrayList<Integer> threes;
private ArrayList<Integer> fours;
private ArrayList<Integer> sixes;
private Predicate<Integer> truePred;
private Predicate<Integer> falsePred;
private Predicate<Integer> evenPred;
private Predicate<Integer> oddPred;
private Predicate<Integer> threePred;
private Predicate<Integer> fourPred;
private final Random random = new Random();

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class IteratorChainTest extends AbstractIteratorTest<String> {
"One", "Two", "Three", "Four", "Five", "Six"
};

protected List<String> list1 = null;
protected List<String> list2 = null;
protected List<String> list3 = null;
protected List<String> list1;
protected List<String> list2;
protected List<String> list3;

public IteratorChainTest() {
super(IteratorChainTest.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class LazyIteratorChainTest extends AbstractIteratorTest<String> {
"One", "Two", "Three", "Four", "Five", "Six"
};

protected List<String> list1 = null;
protected List<String> list2 = null;
protected List<String> list3 = null;
protected List<String> list1;
protected List<String> list2;
protected List<String> list3;

public LazyIteratorChainTest() {
super(LazyIteratorChainTest.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ListIteratorWrapper2Test<E> extends AbstractIteratorTest<E> {
"One", "Two", "Three", "Four", "Five", "Six"
};

protected List<E> list1 = null;
protected List<E> list1;

public ListIteratorWrapper2Test() {
super(ListIteratorWrapper2Test.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ListIteratorWrapperTest<E> extends AbstractIteratorTest<E> {
"One", "Two", "Three", "Four", "Five", "Six"
};

protected List<E> list1 = null;
protected List<E> list1;

public ListIteratorWrapperTest() {
super(ListIteratorWrapperTest.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest<Object> {

protected String[] testArray = { "One", "Two", "Three", "Four", "Five", "Six" };

protected List<String> list1 = null;
protected List<String> list2 = null;
protected List<String> list3 = null;
protected List<Iterator<String>> iteratorList = null;
protected List<String> list1;
protected List<String> list2;
protected List<String> list3;
protected List<Iterator<String>> iteratorList;

public ObjectGraphIteratorTest() {
super(ObjectGraphIteratorTest.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class UniqueFilterIteratorTest<E> extends AbstractIteratorTest<E> {
"One", "Two", "Three", "Four", "Five", "Six"
};

protected List<E> list1 = null;
protected List<E> list1;

public UniqueFilterIteratorTest() {
super(UniqueFilterIteratorTest.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public ZippingIteratorTest() {

//--------------------------------------------------------------- Lifecycle

private ArrayList<Integer> evens = null;
private ArrayList<Integer> odds = null;
private ArrayList<Integer> fib = null;
private ArrayList<Integer> evens;
private ArrayList<Integer> odds;
private ArrayList<Integer> fib;

@BeforeEach
public void setUp() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
* @since 4.1
*/
public class UnmodifiableNavigableSetTest<E> extends AbstractNavigableSetTest<E> {
protected UnmodifiableNavigableSet<E> set = null;
protected ArrayList<E> array = null;
protected UnmodifiableNavigableSet<E> set;
protected ArrayList<E> array;

public UnmodifiableNavigableSetTest() {
super(UnmodifiableNavigableSetTest.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
* @since 3.0
*/
public class UnmodifiableSortedSetTest<E> extends AbstractSortedSetTest<E> {
protected UnmodifiableSortedSet<E> set = null;
protected ArrayList<E> array = null;
protected UnmodifiableSortedSet<E> set;
protected ArrayList<E> array;

public UnmodifiableSortedSetTest() {
super(UnmodifiableSortedSetTest.class.getSimpleName());
Expand Down

0 comments on commit fccb6fc

Please sign in to comment.