File GraphUtil.java
has 600 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.graph;
import de.uniks.networkparser.EntityUtil;
import de.uniks.networkparser.buffer.CharacterBuffer;
import de.uniks.networkparser.interfaces.ObjectCondition;
GraphUtil
has 55 methods (exceeds 20 allowed). Consider refactoring. Open
public class GraphUtil {
private static SimpleList<String> noneDictionary = new SimpleList<String>().with("aircraft", "carp", "deer",
"salmon", "sheep", "trout");
private static SimpleList<String> oesDictionary = new SimpleList<String>().with("hero", "potato", "torpedo");
Method containsClazzAssociation
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static final boolean containsClazzAssociation(SimpleList<GraphMember> visited, Association assoc,
Association other) {
boolean foundAssoc = false;
for (GraphMember checkItem : visited) {
if (checkItem instanceof Association == false || checkItem.getName() == 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 getPlural
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static String getPlural(String singular) {
/* Zischlaut */
if (singular == null || singular.length() < 1) {
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 containsClazzAssociation
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final boolean containsClazzAssociation(SimpleList<GraphMember> visited, Association assoc,
Association other) {
boolean foundAssoc = false;
for (GraphMember checkItem : visited) {
if (checkItem instanceof Association == false || checkItem.getName() == null) {
Method getVisible
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static final Modifier getVisible(GraphMember member) {
if (member == null) {
return Modifier.PACKAGE;
}
Modifier modifier = member.getModifier();
- 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 compareName
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static double compareName(String source, String other) {
if (source == null || other == null) {
return 0;
}
int counter = 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 getParentClazz
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static final Clazz getParentClazz(GraphMember member) {
if (member == null) {
return null;
}
if (member instanceof 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
Avoid deeply nested control flow statements. Open
if (assocB.getClazz() == other.getClazz()) {
/* May be n-m */
assocA.with(Association.MANY);
assocB.with(Association.MANY);
} else {
Method getGraphModel
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static final GraphModel getGraphModel(GraphMember member) {
if (member instanceof GraphModel) {
return (GraphModel) member;
}
Object parent = member.getParent();
- 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 getAnnotations
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static final SimpleSet<Annotation> getAnnotations(GraphMember item) {
if (item == null) {
return null;
}
SimpleSet<Annotation> collection = new SimpleSet<Annotation>();
- 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 setChildren
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static boolean setChildren(GraphMember graphMember, Object children) {
if (graphMember != null ) {
if(children instanceof GraphSimpleSet) {
GraphSimpleSet set = (GraphSimpleSet) children;
if(graphMember.children != set) {
- 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 compareType
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static double compareType(String sourceType, String otherType) {
if (sourceType == null || otherType == null) {
return 1;
}
if (EntityUtil.isNumericType(sourceType) && EntityUtil.isNumericType(otherType)) {
- 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 value;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return Clazz.TYPE_CLASS;
Avoid too many return
statements within this method. Open
return singular.subSequence(0, singular.length() - 1) + "ves";
Avoid too many return
statements within this method. Open
return singular + "s";
Avoid too many return
statements within this method. Open
return singular + "s";
Avoid too many return
statements within this method. Open
return Clazz.TYPE_PATTERNOBJECT;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return Clazz.TYPE_SET;
Avoid too many return
statements within this method. Open
return singular + "es";
Avoid too many return
statements within this method. Open
return -1;
Method removeYou
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static final boolean removeYou(GraphMember value) {
if (value == null) {
return true;
}
value.setParentNode(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 getGraphDiff
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static final GraphSimpleSet getGraphDiff(GraphSimpleSet owner, GraphMember item) {
if (item == null) {
return owner;
}
if (owner == 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 isUndirectional
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static final boolean isUndirectional(Association assoc) {
if (assoc == null) {
return false;
}
if ((assoc.getType() == AssociationTypes.ASSOCIATION || assoc.getType() == AssociationTypes.UNDIRECTIONAL)
- 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 createType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static final String createType(String value) {
if (value == null) {
return Clazz.TYPE_CLASS;
}
String trim = value.trim().toLowerCase();
- 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 (assocB.getName().equals(other.getName())) {
/* Found Link ?? */
foundAssoc = true;
if (assocA.getClazz() == assoc.getClazz()) {
if (assocB.getClazz() == other.getClazz()) {
- 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.equals(Modifier.PACKAGE) || child.equals(Modifier.PRIVATE) || child.equals(Modifier.PUBLIC)
|| child.equals(Modifier.PROTECTED)) {
return modifier;
}
- 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
}
}