Skip to content

Commit

Permalink
Don't initialize an instance or static 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 0dc9cc0 commit 4347431
Show file tree
Hide file tree
Showing 38 changed files with 84 additions and 83 deletions.
1 change: 1 addition & 0 deletions src/main/config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ limitations under the License.
</module>

<module name="TreeWalker">
<module name="ExplicitInitializationCheck" />
<module name="AvoidStarImport">
<property name="excludes" value="org.junit.Assert,org.apache.commons.jexl3.parser"/>
</module>
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/apache/commons/jexl3/JexlBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,25 @@ public static void setDefaultPermissions(final JexlPermissions permissions) {
protected static final int CACHE_THRESHOLD = 64;

/** The JexlUberspect instance. */
private JexlUberspect uberspect = null;
private JexlUberspect uberspect;

/** The {@link JexlUberspect} resolver strategy. */
private JexlUberspect.ResolverStrategy strategy = null;
private JexlUberspect.ResolverStrategy strategy;

/** The set of permissions. */
private JexlPermissions permissions;

/** The sandbox. */
private JexlSandbox sandbox = null;
private JexlSandbox sandbox;

/** The Log to which all JexlEngine messages will be logged. */
private Log logger = null;
private Log logger;

/** Whether error messages will carry debugging information. */
private Boolean debug = null;
private Boolean debug;

/** Whether interrupt throws JexlException.Cancel. */
private Boolean cancellable = null;
private Boolean cancellable;

/** The options. */
private final JexlOptions options = new JexlOptions();
Expand All @@ -127,7 +127,7 @@ public static void setDefaultPermissions(final JexlPermissions permissions) {
private int collectMode = 1;

/** The {@link JexlArithmetic} instance. */
private JexlArithmetic arithmetic = null;
private JexlArithmetic arithmetic;

/** The cache size. */
private int cache = -1;
Expand All @@ -142,10 +142,10 @@ public static void setDefaultPermissions(final JexlPermissions permissions) {
private Charset charset = Charset.defaultCharset();

/** The class loader. */
private ClassLoader loader = null;
private ClassLoader loader;

/** The features. */
private JexlFeatures features = null;
private JexlFeatures features;

/**
* Default constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/jexl3/JexlOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public final class JexlOptions {
/** Default mask .*/
private static int DEFAULT = 1 /*<< CANCELLABLE*/ | 1 << STRICT | 1 << ANTISH | 1 << SAFE;
/** The arithmetic math context. */
private MathContext mathContext = null;
private MathContext mathContext;
/** The arithmetic math scale. */
private int mathScale = Integer.MIN_VALUE;
/** The arithmetic strict math flag. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ protected static Class<?> unboxingClass(final Class<?> parm) {
}

/** The intended class array. */
protected Class<?> commonClass = null;
protected Class<?> commonClass;
/** Whether the array stores numbers. */
protected boolean isNumber = true;
/** Whether we can try unboxing. */
protected boolean unboxing = true;
/** The untyped list of items being added. */
protected final Object[] untyped;
/** Number of added items. */
protected int added = 0;
protected int added;
/** Extended? */
protected final boolean extended;

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/apache/commons/jexl3/internal/Debugger.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
/** The builder to compose messages. */
protected final StringBuilder builder = new StringBuilder();
/** The cause of the issue to debug. */
protected JexlNode cause = null;
protected JexlNode cause;
/** The starting character location offset of the cause in the builder. */
protected int start = 0;
protected int start;
/** The ending character location offset of the cause in the builder. */
protected int end = 0;
protected int end;
/** The indentation level. */
protected int indentLevel = 0;
protected int indentLevel;
/** Perform indentation?. */
protected int indent = 2;
/** accept() relative depth. */
Expand All @@ -144,7 +144,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
/** EOL. */
protected String lf = "\n";
/** Pragmas out. */
protected boolean outputPragmas = false;
protected boolean outputPragmas;

/**
* Creates a Debugger.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/apache/commons/jexl3/internal/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private UberspectHolder() {}
/**
* The default jxlt engine.
*/
protected volatile TemplateEngine jxlt = null;
protected volatile TemplateEngine jxlt;
/**
* Collect all or only dot references.
*/
Expand Down Expand Up @@ -824,7 +824,7 @@ protected static class VarCollector {
/**
* The node that started the collect.
*/
private JexlNode root = null;
private JexlNode root;
/**
* Whether constant array-access is considered equivalent to dot-access;
* if so, > 1 means collect any constant (set,map,...) instead of just
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@
*/
public class Interpreter extends InterpreterBase {
/** Frame height. */
protected int fp = 0;
protected int fp;
/** Symbol values. */
protected final Frame frame;
/** Block micro-frames. */
protected LexicalFrame block = null;
protected LexicalFrame block;

/**
* The thread local interpreter.
Expand Down Expand Up @@ -2025,7 +2025,7 @@ public class AnnotatedCall implements Callable<Object> {
/** The data. */
private final Object data;
/** Tracking whether we processed the annotation. */
private boolean processed = false;
private boolean processed;

/**
* Simple ctor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,15 +833,15 @@ protected class CallDispatcher {
/** Whether solution is cacheable. */
final boolean cacheable;
/** Whether arguments have been narrowed. */
boolean narrow = false;
boolean narrow;
/** The method to call. */
JexlMethod vm = null;
JexlMethod vm;
/** The method invocation target. */
Object target = null;
Object target;
/** The actual arguments. */
Object[] argv = null;
Object[] argv;
/** The cacheable funcall if any. */
Funcall funcall = null;
Funcall funcall;

/**
* Dispatcher ctor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class LexicalFrame extends LexicalScope {
/**
* The stack of values in the lexical frame.
*/
private Deque<Object> stack = null;
private Deque<Object> stack;

/**
* Lexical frame ctor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public class LexicalScope {
/**
* Number of symbols.
*/
protected int count = 0;
protected int count;
/**
* The mask of symbols in the scope.
*/
protected long symbols = 0L;
protected long symbols;
/**
* Symbols after bit 64 (aka symbol 32 when 2 bits per symbol).
*/
protected BitSet moreSymbols = null;
protected BitSet moreSymbols;

/**
* Create a scope.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/apache/commons/jexl3/internal/Scope.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ public final class Scope {
* Each parameter is associated to a symbol and is materialized as an offset in the stacked array used
* during evaluation.
*/
private Map<String, Integer> namedVariables = null;
private Map<String, Integer> namedVariables;
/**
* The map of local captured variables to parent scope variables, ie closure.
*/
private Map<Integer, Integer> capturedVariables = null;
private Map<Integer, Integer> capturedVariables;
/**
* Let symbols.
*/
private LexicalScope lexicalVariables = null;
private LexicalScope lexicalVariables;

/**
* The empty string array.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class SoftCache<K, V> {
/**
* The soft reference to the cache map.
*/
private SoftReference<Map<K, V>> ref = null;
private SoftReference<Map<K, V>> ref;
/**
* The cache r/w lock.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public final class IndexedType implements JexlPropertyGet {
/** The array of getter methods. */
private final Method[] getters;
/** Last get method used. */
private volatile Method get = null;
private volatile Method get;
/** The array of setter methods. */
private final Method[] setters;
/** Last set method used. */
private volatile Method set = null;
private volatile Method set;

/**
* Attempts to find an indexed-property getter in an object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public String get(final String name) {
*/
static class AllowSet extends Names {
/** The map of controlled names and aliases. */
private Map<String, String> names = null;
private Map<String, String> names;

@Override
protected Names copy() {
Expand Down Expand Up @@ -370,7 +370,7 @@ public String get(final String name) {
*/
static class BlockSet extends Names {
/** The set of controlled names. */
private Set<String> names = null;
private Set<String> names;

@Override
protected Names copy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ASTAnnotation extends JexlNode {
*
*/
private static final long serialVersionUID = 1L;
private String name = null;
private String name;

ASTAnnotation(final int id) {
super(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ASTArrayAccess extends JexlLexicalNode {
* However, an expression like 'a?[b]?[c]?...?[b0]' with 64 terms is very unlikely
* to occur in real life and a bad idea anyhow.
*/
private long safe = 0;
private long safe;

public ASTArrayAccess(final int id) {
super(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class ASTIdentifier extends JexlNode {
*
*/
private static final long serialVersionUID = 1L;
protected String name = null;
protected String name;
protected int symbol = -1;
protected int flags = 0;
protected int flags;

/** The redefined variable flag. */
private static final int REDEFINED = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public class ASTIdentifierAccess extends JexlNode {
*
*/
private static final long serialVersionUID = 1L;
private String name = null;
private Integer identifier = null;
private String name;
private Integer identifier;

ASTIdentifierAccess(final int id) {
super(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class ASTJexlScript extends JexlLexicalNode {
/** serial uid.*/
private static final long serialVersionUID = 202112111533L;
/** The pragmas. */
private Map<String, Object> pragmas = null;
private Map<String, Object> pragmas;
/** Features. */
private transient JexlFeatures features = null;
/** The script scope. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class ASTJxltLiteral extends JexlNode {
/** serial uid.*/
private static final long serialVersionUID = 1L;
/** The actual literal value. */
private String literal = null;
private String literal;
/** The expression (parsed). */
private transient JxltEngine.Expression jxltExpression = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ASTQualifiedIdentifier extends JexlNode {
*
*/
private static final long serialVersionUID = 1L;
protected String name = null;
protected String name;

ASTQualifiedIdentifier(final int id) {
super(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public final class ASTRegexLiteral extends JexlNode implements JexlNode.Constant
private static final long serialVersionUID = 1L;
/** The actual literal value; the inherited 'value' member may host a cached getter. */

private Pattern literal = null;
private Pattern literal;

ASTRegexLiteral(final int id) {
super(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class ASTStringLiteral extends JexlNode implements JexlNode.Constan
*/
private static final long serialVersionUID = 1L;
/** The actual literal value; the inherited 'value' member may host a cached getter. */
private String literal = null;
private String literal;

ASTStringLiteral(final int id) {
super(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
*/
public class ExtensibleNode extends JexlNode {
/** Whether this array/set/map is constant or not. */
protected boolean constant = false;
protected boolean constant;
/** Whether this array/set/map is extended or not. */
private boolean extended = false;
private boolean extended;

public ExtensibleNode(final int id) {
super(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public abstract class JexlLexicalNode extends JexlNode implements JexlParser.LexicalUnit {
private static final long serialVersionUID = 1L;
/** The local lexical scope, local information about let/const. */
private LexicalScope lexicalScope = null;
private LexicalScope lexicalScope;

public JexlLexicalNode(final int id) {
super(id);
Expand Down
Loading

0 comments on commit 4347431

Please sign in to comment.