File JsonTokener.java
has 564 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.json;
import java.util.Collection;
/*
NetworkParser
Method decoding
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
private Object decoding(Object target, JsonObject jsonObject, MapEntity map) {
/* JSONArray jsonArray; */
if (map == null) {
return null;
}
- 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 parseValue
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
private void parseValue(Object target, String property, Object value, SendableEntityCreator creator,
MapEntity map) {
/* FIXME IF STATGEGY IS UPDATE SET NEW VALUE */
if (map == 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 decoding
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public Object decoding(JsonObject jsonObject, MapEntity map, boolean kid) {
if (map == null) {
return null;
}
if (jsonObject == null) {
- 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 parsingSimpleEntityXML
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
private BaseItem parsingSimpleEntityXML(JsonObject parent, XMLEntity newValue) {
/* <TAG PARAM>CHILDREN</TAG> */
if (newValue == null) {
return null;
}
- 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 decodingSimple
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
public Object decodingSimple(JsonObject jsonObject, Object target, SendableEntityCreator creator) {
if (jsonObject == null || target == null || creator == null) {
return null;
}
String[] properties = creator.getProperties();
- 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 parsingEntity
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
private Entity parsingEntity(Entity entity, Buffer buffer) {
if (buffer == null || entity == null) {
return entity;
}
String 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 parsingEntity
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Entity parsingEntity(Entity entity, Buffer buffer) {
if (buffer == null || entity == null) {
return entity;
}
String key;
Method parsingEntity
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private EntityList parsingEntity(EntityList entityList, Buffer buffer) {
/* FIXME REMOVE */
if (buffer == null) {
return null;
}
- 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 parsingSimpleEntityXML
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
private BaseItem parsingSimpleEntityXML(JsonObject parent, XMLEntity newValue) {
/* <TAG PARAM>CHILDREN</TAG> */
if (newValue == null) {
return null;
}
Method parseEntityProp
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private void parseEntityProp(JsonObject props, Object propValue, String prop) {
if (propValue != null) {
if (propValue instanceof XMLEntity) {
if (props.containsKey(prop)) {
Object child = props.get(prop);
- 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 decoding
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Object decoding(JsonObject jsonObject, MapEntity map, boolean kid) {
if (map == null) {
return null;
}
if (jsonObject == null) {
Method parseValue
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void parseValue(Object target, String property, Object value, SendableEntityCreator creator,
MapEntity map) {
/* FIXME IF STATGEGY IS UPDATE SET NEW VALUE */
if (map == null) {
return;
Method decoding
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Object decoding(Object target, JsonObject jsonObject, MapEntity map) {
/* JSONArray jsonArray; */
if (map == null) {
return null;
}
Method parsingEntityXML
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private BaseItem parsingEntityXML(JsonObject parent, SimpleKeyValueList<?, ?> newValue) {
if (newValue instanceof XMLEntity) {
XMLEntity xmlEntity = (XMLEntity) newValue;
if (simpleFormat) {
- 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 parsingEntity
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private EntityList parsingEntity(EntityList entityList, Buffer buffer) {
/* FIXME REMOVE */
if (buffer == null) {
return null;
}
Method decodingSimple
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Object decodingSimple(JsonObject jsonObject, Object target, SendableEntityCreator creator) {
if (jsonObject == null || target == null || creator == null) {
return null;
}
String[] properties = creator.getProperties();
Method parseEntity
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public JsonObject parseEntity(JsonObject parent, SimpleKeyValueList<?, ?> newValue) {
if (newValue instanceof XMLEntity) {
XMLEntity xmlEntity = (XMLEntity) newValue;
parent.put(IdMap.CLASS, xmlEntity.getTag());
JsonObject props = new JsonObject();
- 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 nextValue
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public Object nextValue(Buffer buffer, BaseItem creator, boolean allowQuote, boolean allowDuppleMarks,
char stopChar) {
if (buffer == null) {
return null;
Method parsingEntityXML
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private BaseItem parsingEntityXML(JsonObject parent, SimpleKeyValueList<?, ?> newValue) {
if (newValue instanceof XMLEntity) {
XMLEntity xmlEntity = (XMLEntity) newValue;
if (simpleFormat) {
Avoid deeply nested control flow statements. Open
if (jsonProp.has(property)) {
Object obj = jsonProp.get(property);
parseValue(target, property, obj, creator, map);
} else {
Object defaultValue = creator.getValue(prototype, property);
Method nextValue
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public Object nextValue(Buffer buffer, BaseItem creator, boolean allowQuote, boolean allowDuppleMarks,
char stopChar) {
Method parseValue
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private void parseValue(Object target, String property, Object value, SendableEntityCreator creator,
MapEntity map) {
Method nextValue
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
@Override
public Object nextValue(Buffer buffer, BaseItem creator, boolean allowQuote, boolean allowDuppleMarks,
char stopChar) {
if (buffer == null) {
return null;
- 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 null;
Avoid too many return
statements within this method. Open
return super.nextValue(buffer, creator, allowQuote, allowDuppleMarks, stopChar);
Avoid too many return
statements within this method. Open
return parsingEntity((Entity) parent, buffer);
Avoid too many return
statements within this method. Open
return item;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return entity;
Avoid too many return
statements within this method. Open
return entity;
Avoid too many return
statements within this method. Open
return entityList;
Avoid too many return
statements within this method. Open
return null;
FIXME found Open
/* FIXME IF STATGEGY IS UPDATE SET NEW VALUE */
- Exclude checks
FIXME found Open
/* FIXME REMOVE */
- Exclude checks
These nested if statements could be combined Open
if (isError(this, "parseToEntity", NetworkParserLog.ERROR_TYP_PARSING, entity)) {
throw new SimpleException("A JsonObject text must begin with '{' \n" + buffer, this);
}
- 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
}
}