Method parsing
has a Cognitive Complexity of 101 (exceeds 5 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
private void parsing(XMLEntity xmlEntity, SendableEntityCreator entityFactory, Object entityObject, String rootId) {
if (xmlEntity == null || this.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
File EMFTokener.java
has 836 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.xml;
/*
NetworkParser
The MIT License
Method decoding
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
private GraphList decoding(XMLEntity ecore, GraphList model) {
if (model == null) {
model = new GraphList();
}
if (ecore == 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 parsing
has 142 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
private void parsing(XMLEntity xmlEntity, SendableEntityCreator entityFactory, Object entityObject, String rootId) {
if (xmlEntity == null || this.map == null) {
return;
}
Method decodingClassModel
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
private Object decodingClassModel(XMLEntity values, GraphModel model) {
if (values == null || model == null) {
return null;
}
SimpleKeyValueList<String, Clazz> items = new SimpleKeyValueList<String, Clazz>();
- 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 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
private GraphList decoding(XMLEntity ecore, GraphList model) {
if (model == null) {
model = new GraphList();
}
if (ecore == null) {
Method getRef
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
private SimpleList<String> getRef(String value, XMLEntity xmlEntity, SendableEntityCreator rootFactory) {
if (value == null) {
return null;
}
SimpleList<String> result = new SimpleList<String>();
- 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 encodeChildren
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private void encodeChildren(Object entity, XMLEntity parent, MapEntity map) {
SendableEntityCreator creatorClass = getCreatorClass(entity);
if (creatorClass == 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 decode
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public Object decode(MapEntity map, Buffer buffer, Object root) {
skipHeader(buffer);
XMLEntity xmlEntity = new XMLEntity();
xmlEntity.withValue(buffer);
if (EPACKAGE.equals(xmlEntity.getTag())) {
- 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 decode
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Object decode(MapEntity map, Buffer buffer, Object root) {
skipHeader(buffer);
XMLEntity xmlEntity = new XMLEntity();
xmlEntity.withValue(buffer);
if (EPACKAGE.equals(xmlEntity.getTag())) {
Method encodePackagedElementClass
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public void encodePackagedElementClass(XMLEntity root, Clazz clazz) {
if (clazz == null || root == null) {
return;
}
root.withType("packagedElement");
- 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
EMFTokener
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
public class EMFTokener extends Tokener {
public static final String ECORE = "ecore";
public static final String EPACKAGE = "ecore:EPackage";
public static final String EAttribute = "eAttributes";
public static final String ECLASS = "eClassifiers";
Method encodeClassModel
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public XMLEntity encodeClassModel(GraphList entity, MapEntity map) {
XMLContainer container = new XMLContainer();
container.withStandardPrefix();
if (entity == null || map == null) {
return container;
- 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 decodingClassModel
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Object decodingClassModel(XMLEntity values, GraphModel model) {
if (values == null || model == null) {
return null;
}
SimpleKeyValueList<String, Clazz> items = new SimpleKeyValueList<String, Clazz>();
Method encodeChildren
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void encodeChildren(Object entity, XMLEntity parent, MapEntity map) {
SendableEntityCreator creatorClass = getCreatorClass(entity);
if (creatorClass == null) {
return;
}
Method encodeClassModel
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public XMLEntity encodeClassModel(GraphList entity, MapEntity map) {
XMLContainer container = new XMLContainer();
container.withStandardPrefix();
if (entity == null || map == null) {
return container;
Method encodePackagedElementClass
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void encodePackagedElementClass(XMLEntity root, Clazz clazz) {
if (clazz == null || root == null) {
return;
}
root.withType("packagedElement");
Method getOrCreate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private Association getOrCreate(SimpleKeyValueList<String, Association> items, GraphList model, String className,
String roleName) {
if (items == 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 getRef
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private SimpleList<String> getRef(String value, XMLEntity xmlEntity, SendableEntityCreator rootFactory) {
if (value == null) {
return null;
}
SimpleList<String> result = new SimpleList<String>();
Method encodeOwnedOperation
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void encodeOwnedOperation(XMLEntity root, Method method) {
if (root == null || method == null) {
return;
}
root.withType("ownedOperation");
Method getOrCreate
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Association getOrCreate(SimpleKeyValueList<String, Association> items, GraphList model, String className,
String roleName) {
if (items == null) {
return null;
}
Method encodeOwnedValue
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void encodeOwnedValue(XMLEntity root, Value value) {
if (root == null || value == null) {
return;
}
if (value instanceof Attribute) {
Method skipHeader
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public String skipHeader(Buffer buffer) {
if (buffer == null) {
return "";
}
boolean skip = false;
Method skipHeader
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public String skipHeader(Buffer buffer) {
if (buffer == null) {
return "";
}
boolean skip = 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
Avoid deeply nested control flow statements. Open
if (key.equals(assoc.getName())) {
found = assoc;
break;
}
Avoid deeply nested control flow statements. Open
if (EntityUtil.isEMFType(etyp)) {
etyp = etyp.substring(1);
}
Avoid deeply nested control flow statements. Open
for (String ref : refs) {
Association back = new Association(items.get(ref));
found.with(back);
}
Avoid deeply nested control flow statements. Open
if (EntityUtil.isPrimitiveType(etyp.toLowerCase())) {
etyp = etyp.toLowerCase();
}
Avoid deeply nested control flow statements. Open
if (rootCollection != null) {
rootCollection.add(object);
} else {
entityFactory.setValue(entityObject, tag, object, "");
}
Method encodeOwnedOperation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public void encodeOwnedOperation(XMLEntity root, Method method) {
if (root == null || method == null) {
return;
}
root.withType("ownedOperation");
- 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 deeply nested control flow statements. Open
if (referenceChild.size() > 0) {
referenceChild.add(' ');
}
Avoid deeply nested control flow statements. Open
if (entityObject instanceof Collection<?>) {
rootCollection = (Collection<Object>) entityObject;
}
Avoid too many return
statements within this method. Open
return rootObject;
Avoid too many return
statements within this method. Open
return decodingClassModel(xmlEntity, model);
Method encodeOwnedValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public void encodeOwnedValue(XMLEntity root, Value value) {
if (root == null || value == null) {
return;
}
if (value instanceof Attribute) {
- 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
TODO found Open
/* TODO CREATING METHOD BODY */
- Exclude checks
These nested if statements could be combined Open
if (((Number) upperValue).intValue() != 1) {
tgtAssoc.with(Association.MANY);
}
- 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
}
}