Method fixClassModel
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
public boolean fixClassModel() {
Clazz[] classes = getClazzes().toArray(new Clazz[getClazzes().size()]);
SimpleSet<Clazz> visited = new SimpleSet<Clazz>();
String packageName = null;
for (Clazz item : classes) {
- 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 fixClassModel
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
private boolean fixClassModel(Clazz item, SimpleSet<Clazz> visited) {
/* Run over Interfaces, SuperClazzes, KidClazzes, Associations */
AssociationSet assocs = item.getAssociations();
for (Association role : assocs) {
if (item.repairAssociation(role, this.renameAttributes) == 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
File GraphModel.java
has 309 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.graph;
import java.util.Iterator;
import de.uniks.networkparser.EntityUtil;
Method getValue
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
@Override
public Object getValue(String attribute) {
if (PROPERTY_CLAZZ.equalsIgnoreCase(attribute)) {
return getClazzes();
}
- 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 fixClassModel
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean fixClassModel(Clazz item, SimpleSet<Clazz> visited) {
/* Run over Interfaces, SuperClazzes, KidClazzes, Associations */
AssociationSet assocs = item.getAssociations();
for (Association role : assocs) {
if (item.repairAssociation(role, this.renameAttributes) == false) {
Method fixClassModel
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean fixClassModel() {
Clazz[] classes = getClazzes().toArray(new Clazz[getClazzes().size()]);
SimpleSet<Clazz> visited = new SimpleSet<Clazz>();
String packageName = null;
for (Clazz item : classes) {
Method clearAddOnClazzes
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected boolean clearAddOnClazzes() {
if (this.children == null) {
return true;
}
if (this.children instanceof GraphSimpleSet == 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 createClazz
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public Clazz createClazz(String name) {
if (name == null || children == null
|| (children instanceof Clazz && name.equals(((Clazz) children).getName()))) {
Clazz clazz = createInstance(name);
clazz.setClassModel(this);
- 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 getClazzes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public ClazzSet getClazzes(Condition<?>... filters) {
ClazzSet collection = new ClazzSet();
if (children == null) {
return collection;
}
- 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 clearAddOnClazzes
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected boolean clearAddOnClazzes() {
if (this.children == null) {
return true;
}
if (this.children instanceof GraphSimpleSet == false) {
Avoid deeply nested control flow statements. Open
if (no < 'a' || no > 'z') {
if (name.equals(name.toUpperCase())) {
attribute.setName(name.toLowerCase());
} else {
attribute.setName(EntityUtil.downFirstChar(name));
Avoid deeply nested control flow statements. Open
if (name == null || name.length() < 1) {
item.remove(attribute);
continue;
}
Avoid deeply nested control flow statements. Open
if (value != null) {
String type = EntityUtil.shortClassName(value.getClass().getName());
if (attributes.size() > no) {
Attribute attribute = attributes.get(no);
if (attribute.getType().getName(true).equals(type)) {
Avoid too many return
statements within this method. Open
return super.getValue(attribute);
Method fixDataType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private void fixDataType(DataType dataType) {
if (dataType == null) {
return;
}
Clazz clazz = dataType.getClazz();
- 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 (check(child, filters)) {
collection.add((Clazz) 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
}
}