File Clazz.java
has 797 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.graph;
import de.uniks.networkparser.EntityUtil;
/*
The MIT License
Method repairAssociation
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
protected boolean repairAssociation(Association assoc, boolean renameName) {
if (assoc == null || assoc.getOther() == null) {
return false;
}
if (AssociationTypes.IMPLEMENTS.equals(assoc.getType()) == 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 parseSuperElements
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
protected void parseSuperElements(ClazzSet superClasses, SimpleSet<?> existsElements, SimpleSet<?> newExistElements,
SimpleSet<?> newElements, Condition<?>... filters) {
if (this.children == null || existsElements == 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
Clazz
has 47 methods (exceeds 20 allowed). Consider refactoring. Open
public class Clazz extends GraphEntity {
public static final String TYPE_CLASS = "class";
public static final String TYPE_ENUMERATION = "enum";
public static final String TYPE_INTERFACE = "interface";
public static final String TYPE_CREATOR = "creator";
Method getValue
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
@Override
public Object getValue(String attribute) {
if (attribute == 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 withSuperClazz
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public Clazz withSuperClazz(Clazz... values) {
AssociationTypes type = AssociationTypes.GENERALISATION;
if (values != null) {
if (values.length == 1) {
- 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 getAttributes
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public AttributeSet getAttributes(Condition<?>... filters) {
AttributeSet collection = new AttributeSet();
if (this.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 getMethods
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public MethodSet getMethods(Condition<?>... filters) {
MethodSet collection = new MethodSet();
if (this.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 createAssociation
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected boolean createAssociation(AssociationTypes direction, AssociationTypes backDirection, Clazz... values) {
if (values == null) {
return false;
}
AssociationSet associations = getAssociations();
- 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 repairAssociation
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected boolean repairAssociation(Association assoc, boolean renameName) {
if (assoc == null || assoc.getOther() == null) {
return false;
}
if (AssociationTypes.IMPLEMENTS.equals(assoc.getType()) == false
Method withAssoc
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public Clazz withAssoc(Clazz tgtClass, int... cardinality) {
if (tgtClass == null || tgtClass.getName() == null) {
return this;
}
int tgtCardinality = 1;
- 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 remove
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean remove(GraphMember member) {
if (this.children == null || member == null) {
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 getValue
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public Object getValue(String attribute) {
if (attribute == null) {
return null;
}
Method parseSuperElements
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void parseSuperElements(ClazzSet superClasses, SimpleSet<?> existsElements, SimpleSet<?> newExistElements,
SimpleSet<?> newElements, Condition<?>... filters) {
if (this.children == null || existsElements == null) {
return;
}
Method repairAssociations
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private void repairAssociations() {
if (this.children == null) {
return;
}
if (this.children instanceof Association) {
- 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 getAttributes
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public AttributeSet getAttributes(Condition<?>... filters) {
AttributeSet collection = new AttributeSet();
if (this.children == null) {
return collection;
}
Method getMethods
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public MethodSet getMethods(Condition<?>... filters) {
MethodSet collection = new MethodSet();
if (this.children == null) {
return collection;
}
Method withAssoc
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Clazz withAssoc(Clazz tgtClass, int... cardinality) {
if (tgtClass == null || tgtClass.getName() == null) {
return this;
}
int tgtCardinality = 1;
Method withSuperClazz
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Clazz withSuperClazz(Clazz... values) {
AssociationTypes type = AssociationTypes.GENERALISATION;
if (values != null) {
if (values.length == 1) {
Method getAssociations
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
@Override
public AssociationSet getAssociations(Condition<?>... filters) {
AssociationSet collection = super.getAssociations(filters);
boolean isInterface = TYPE_INTERFACE.equals(getType());
boolean isAbstract = getModifier().has(Modifier.ABSTRACT);
- 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 getValues
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public SimpleSet<Literal> getValues() {
SimpleSet<Literal> collection = new SimpleSet<Literal>();
if (this.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 getImports
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public SimpleSet<Import> getImports() {
SimpleSet<Import> collection = new SimpleSet<Import>();
if (this.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 getEdgeClazzes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected ClazzSet getEdgeClazzes(AssociationTypes typ, AssociationTypes otherTyp) {
ClazzSet kidClazzes = new ClazzSet();
if (this.children == null || typ == null) {
return kidClazzes;
}
- 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 (assoc.getType() == direction && assoc.getOtherType() == backDirection) {
if (assoc.contains(item, true, false) == false) {
assoc.getOther().setParentNode(item);
return true;
}
Avoid deeply nested control flow statements. Open
if (assoc.getOther().getParents().size() == 1) {
this.remove(assoc);
} else {
assoc.getOther().withoutParent(clazz);
}
Method withBidirectional
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public Clazz withBidirectional(Clazz tgtClass, String tgtRoleName, int tgtCardinality, String srcRoleName,
int srcCardinality) {
Method createBidirectional
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public Association createBidirectional(Clazz tgtClass, String tgtRoleName, int tgtCardinality, String srcRoleName,
int srcCardinality) {
Method withAssoc
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public Clazz withAssoc(Clazz tgtClass, String tgtRoleName, int tgtCardinality, String srcRoleName,
int srcCardinality) {
Method parseSuperElements
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected void parseSuperElements(ClazzSet superClasses, SimpleSet<?> existsElements, SimpleSet<?> newExistElements,
SimpleSet<?> newElements, Condition<?>... filters) {
Method enableEnumeration
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public Clazz enableEnumeration(Object... literals) {
this.withType(TYPE_ENUMERATION);
if (literals == null) {
return 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
Avoid too many return
statements within this method. Open
return implementsClazz.toString(", ");
Avoid too many return
statements within this method. Open
return this.getName(false);
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return attributes.getValue(attribute.substring(pos + 1));
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return clazzes.toString(", ");
Avoid too many return
statements within this method. Open
return this.getType();
Avoid too many return
statements within this method. Open
return buffer.toString();
Avoid too many return
statements within this method. Open
return super.getValue(attribute);
Avoid too many return
statements within this method. Open
return attributes;
These nested if statements could be combined Open
if (assoc.contains(item, true, false) == false) {
assoc.getOther().setParentNode(item);
return true;
}
- 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 (assoc.getOther().contains(clazz, true, true)) {
if (assoc.getOther().getParents().size() == 1) {
this.remove(assoc);
} else {
assoc.getOther().withoutParent(clazz);
- 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 (assoc.getCardinality() != otherAssoc.getCardinality()) {
/* Self assoc with same RoleName but other Cardinality */
return false;
}
- 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
}
}