Don't initialize an instance or static variable to its default value

This commit is contained in:
Gary Gregory 2023-10-27 10:56:01 -04:00
parent 8c696abe85
commit aa405f9877
6 changed files with 9 additions and 8 deletions

View File

@ -36,6 +36,7 @@ limitations under the License.
<property name="file" value="src/site/resources/checkstyle/checkstyle-suppressions.xml"/>
</module>
<module name="TreeWalker">
<module name="ExplicitInitializationCheck" />
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="RedundantImport"/>

View File

@ -54,7 +54,7 @@ public class DiffBuilderTest extends AbstractLangTest {
private long[] longArrayField = {1L};
private short shortField = 1;
private short[] shortArrayField = {1};
private Object objectField = null;
private Object objectField;
private Object[] objectArrayField = {null};
@Override

View File

@ -128,13 +128,13 @@ public class HashCodeBuilderTest extends AbstractLangTest {
static class TestObjectWithMultipleFields {
@SuppressWarnings("unused")
private int one = 0;
private int one;
@SuppressWarnings("unused")
private int two = 0;
private int two;
@SuppressWarnings("unused")
private int three = 0;
private int three;
TestObjectWithMultipleFields(final int one, final int two, final int three) {
this.one = one;

View File

@ -306,7 +306,7 @@ public class BackgroundInitializerTest extends AbstractLangTest {
/** A latch tests can use to control when initialize completes. */
final CountDownLatch latch = new CountDownLatch(1);
boolean waitForLatch = false;
boolean waitForLatch;
/** An object containing the state we are testing */
CloseableCounter counter = new CloseableCounter();

View File

@ -439,7 +439,7 @@ public class MultiBackgroundInitializerTest extends AbstractLangTest {
/** A latch tests can use to control when initialize completes. */
final CountDownLatch latch = new CountDownLatch(1);
boolean waitForLatch = false;
boolean waitForLatch;
public void enableLatch() {
waitForLatch = true;

View File

@ -20,8 +20,8 @@ package org.apache.commons.lang3.reflect.testbed;
*/
class Parent implements Foo {
public String s = "s";
protected boolean b = false;
int i = 0;
protected boolean b;
int i;
@SuppressWarnings("unused")
private final double d = 0.0;