File AbstractArray.java
has 1224 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.list;
/*
* NetworkParser The MIT License Copyright (c) 2010-2016 Stefan Lindel
* https://www.github.com/fujaba/NetworkParser/
Method getValue
has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring. Open
public Object getValue(Object key) {
int pos = indexOf(key);
if (pos >= 0) {
if ((flag & MAP) == MAP) {
return this.getByIndex(SMALL_VALUE, pos + index, size);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
AbstractArray
has 78 methods (exceeds 20 allowed). Consider refactoring. Open
public abstract class AbstractArray<V> implements BaseItem {
/** Is Allow Duplicate Items in List */
public static final byte ALLOWDUPLICATE = 0x01;
/** Is Allow Empty Value in List (null) */
public static final byte ALLOWEMPTYVALUE = 0x02;
Method removeItem
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
protected Object removeItem(int index, int offset, int oldIndex) {
if (elements == null) {
return null;
}
Object[] items;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method grow
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
int grow(int minCapacity) {
int arrayFlag = getArrayFlag(minCapacity);
if (elements == null) {
/* Init List */
int newSize = minCapacity + minCapacity / 2 + 5;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getPosition
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
int getPosition(Object o, int offset, boolean last) {
if (o == null || elements == null) {
return REMOVED;
}
Object[] hashCodes;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getValue
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Object getValue(Object key) {
int pos = indexOf(key);
if (pos >= 0) {
if ((flag & MAP) == MAP) {
return this.getByIndex(SMALL_VALUE, pos + index, size);
Method removeItem
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected Object removeItem(int index, int offset, int oldIndex) {
if (elements == null) {
return null;
}
Object[] items;
Method removeByIndex
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected Object removeByIndex(int index, int offset, int offsetIndex) {
Object item = removeItem(index, offset, offsetIndex);
if (item != null) {
size--;
if (shrink(size) == false) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method addKey
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected int addKey(int pos, Object element, int size) {
Object[] keys;
if (isComplex(size)) {
keys = (Object[]) elements[SMALL_KEY];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method containsAny
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public boolean containsAny(Object... c) {
if (c == null || c.length < 1)
return false;
if (c.length > 1) {
for (Object e : c) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method hashKeyPos
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
final int hashKeyPos(Object element, int size) {
if (element == null || isReadOnly()) {
return REMOVED;
}
if (isComparator()) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method shrink
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
boolean shrink(int minCapacity) {
/* Shrink the Array */
if (minCapacity == 0) {
elements = null;
this.index = 0;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method grow
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
int grow(int minCapacity) {
int arrayFlag = getArrayFlag(minCapacity);
if (elements == null) {
/* Init List */
int newSize = minCapacity + minCapacity / 2 + 5;
Method getPosition
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
int getPosition(Object o, int offset, boolean last) {
if (o == null || elements == null) {
return REMOVED;
}
Object[] hashCodes;
Method addKeyValue
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected int addKeyValue(int pos, Object key, Object value) {
Object[] keys = (Object[]) elements[SMALL_KEY];
Object[] values = (Object[]) elements[SMALL_VALUE];
if (pos == 0 && this.size > 0) {
if (this.index == 0) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method withList
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public AbstractArray<V> withList(Collection<?> list) {
if (list == null || this.size + list.size() == 0) {
return this;
}
int newSize = this.size + list.size();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method addKey
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected int addKey(int pos, Object element, int size) {
Object[] keys;
if (isComplex(size)) {
keys = (Object[]) elements[SMALL_KEY];
Method shrink
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
boolean shrink(int minCapacity) {
/* Shrink the Array */
if (minCapacity == 0) {
elements = null;
this.index = 0;
Method move
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean move(int from, int to) {
if (from == to) {
return true;
}
if (from < 0 || to < 0 || from > size() || to > size()) {
Method getByIndex
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected Object getByIndex(int offset, int index, int size) {
if (size == 0 || elements == null) {
return null;
}
if (index < 0) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method search
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
int search(Object[] items, Object o) {
int pos = this.index;
if (pos == 0) {
while (pos < this.size) {
if (checkValue(o, items[pos])) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method hasKeyAndPos
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected int hasKeyAndPos(Object element) {
if (element == null || isReadOnly())
return REMOVED;
if (isComparator()) {
for (int i = 0; i < this.size; i++) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method addKeyValue
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected int addKeyValue(int pos, Object key, Object value) {
Object[] keys = (Object[]) elements[SMALL_KEY];
Object[] values = (Object[]) elements[SMALL_VALUE];
if (pos == 0 && this.size > 0) {
if (this.index == 0) {
Method clear
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void clear() {
int arrayFlag = getArrayFlag(size);
if (arrayFlag < 1) {
this.elements = null;
return;
Method toString
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public String toString() {
StringBuilder sb = new StringBuilder();
if ((flag & BIDI) > 0) {
sb.append("BIDI-Map ");
} else if ((flag & MAP) > 0) {
Method removeByIndex
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected Object removeByIndex(int index, int offset, int offsetIndex) {
Object item = removeItem(index, offset, offsetIndex);
if (item != null) {
size--;
if (shrink(size) == false) {
Method toString
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public String toString() {
StringBuilder sb = new StringBuilder();
if ((flag & BIDI) > 0) {
sb.append("BIDI-Map ");
} else if ((flag & MAP) > 0) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method move
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public boolean move(int from, int to) {
if (from == to) {
return true;
}
if (from < 0 || to < 0 || from > size() || to > size()) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method fireProperty
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected boolean fireProperty(String type, Object oldElement, Object newElement, Object beforeElement, int index,
Object value) {
Method clear
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public void clear() {
int arrayFlag = getArrayFlag(size);
if (arrayFlag < 1) {
this.elements = null;
return;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method add
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean add(Object... values) {
if (values == null || values.length < 1) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method transformIndex
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private int transformIndex(int index, int size) {
if (elements[DELETED] != null) {
Object[] items = (Object[]) elements[DELETED];
for (int i = 0; i < items.length; i++) {
if (((Integer) items[i]) > index) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseItem
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected String parseItem(EntityStringConverter converter) {
CharacterBuffer sb = new CharacterBuffer();
int len = this.size();
for (int i = 0; i < len; i++) {
Object key = getKeyByIndex(i);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return REMOVED;
Avoid too many return
statements within this method. Open
return child;
Avoid too many return
statements within this method. Open
return minCapacity;
Avoid too many return
statements within this method. Open
return this.size;
Avoid too many return
statements within this method. Open
return newSize * 2;
Avoid too many return
statements within this method. Open
return newSize * 2;
Avoid too many return
statements within this method. Open
return size;
Avoid too many return
statements within this method. Open
return ((SimpleKeyValueList<?, ?>) list.get(id)).getValue(keyString.substring(end + 1));
Avoid too many return
statements within this method. Open
return ((AbstractArray<?>) child).getValue(keyString.substring(end + 1));
Avoid too many return
statements within this method. Open
return list.get(id);
Avoid too many return
statements within this method. Open
return indexItem;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return 1;
Avoid too many return
statements within this method. Open
return REMOVED;
Avoid too many return
statements within this method. Open
return result;
Avoid too many return
statements within this method. Open
return null;
Method retransformIndex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private int retransformIndex(int index, int size) {
if (elements[DELETED] != null) {
Object[] items = (Object[]) elements[DELETED];
for (int i = 0; i < items.length; i++) {
if (((Integer) items[i]) > index) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method toArray
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public <T> T[] toArray(T[] a) {
if (a == null) {
return null;
}
Object[] elementData;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getArrayFlag
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
final int getArrayFlag(int size) {
if (size == 0) {
return 0;
}
if ((flag & BIDI) > 0) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method subList
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public BaseItem subList(int fromIndex, int toIndex) {
BaseItem newInstance = getNewList(false);
if (fromIndex < 0) {
fromIndex += size;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method pack
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public void pack() {
if (elements == null) {
return;
}
boolean complex = isComplex(size);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
These nested if statements could be combined Open
if (indexOf(element, size) >= 0) {
return REMOVED;
}
- Read upRead up
- Exclude checks
CollapsibleIfStatements
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
Example:
void bar() {
if (x) { // original implementation
if (y) {
// do stuff
}
}
}
void bar() {
if (x && y) { // optimized implementation
// do stuff
}
}
These nested if statements could be combined Open
if (a instanceof String && b instanceof String) {
return ((String) a).equalsIgnoreCase((String) b);
}
- Read upRead up
- Exclude checks
CollapsibleIfStatements
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
Example:
void bar() {
if (x) { // original implementation
if (y) {
// do stuff
}
}
}
void bar() {
if (x && y) { // optimized implementation
// do stuff
}
}
These nested if statements could be combined Open
if ("size".equalsIgnoreCase(keyString)) {
return this.size();
}
- Read upRead up
- Exclude checks
CollapsibleIfStatements
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
Example:
void bar() {
if (x) { // original implementation
if (y) {
// do stuff
}
}
}
void bar() {
if (x && y) { // optimized implementation
// do stuff
}
}
These nested if statements could be combined Open
if (minCapacity > elements.length) {
int newSize = minCapacity + minCapacity / 2 + 5;
resizeSmall(newSize);
return newSize;
}
- Read upRead up
- Exclude checks
CollapsibleIfStatements
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
Example:
void bar() {
if (x) { // original implementation
if (y) {
// do stuff
}
}
}
void bar() {
if (x && y) { // optimized implementation
// do stuff
}
}
These nested if statements could be combined Open
if (child instanceof AbstractList) {
if (end == len + 2) {
/* Get List */
BaseItem result = this.getNewList(true);
AbstractList<?> items = (AbstractList<?>) child;
- Read upRead up
- Exclude checks
CollapsibleIfStatements
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.
Example:
void bar() {
if (x) { // original implementation
if (y) {
// do stuff
}
}
}
void bar() {
if (x && y) { // optimized implementation
// do stuff
}
}