File TemplateResultFragment.java
has 552 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.parser;
/*
The MIT License
Method getValue
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
@Override
public Object getValue(Object entity, String attribute) {
if (entity instanceof TemplateResultFragment == false) {
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 put
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
@Override
public String put(String label, Object object) {
if (label == 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
TemplateResultFragment
has 43 methods (exceeds 20 allowed). Consider refactoring. Open
public class TemplateResultFragment
implements Comparable<TemplateResultFragment>, SendableEntityCreator, ObjectCondition, LocalisationInterface {
public static final String PROPERTY_PARENT = "parent";
public static final String PROPERTY_CHILD = "child";
public static final String PROPERTY_CLONE = "clone";
Method setValue
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean setValue(Object entity, String attribute, Object value, String type) {
if (entity instanceof TemplateResultFragment == false) {
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 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public Object getValue(Object entity, String attribute) {
if (entity instanceof TemplateResultFragment == false) {
return null;
}
Method update
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean update(Object value) {
if (value instanceof ObjectCondition == false) {
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 setValue
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean setValue(Object entity, String attribute, Object value, String type) {
if (entity instanceof TemplateResultFragment == false) {
return false;
}
Method put
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public String put(String label, Object object) {
if (label == null) {
return null;
}
Method replacing
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public String replacing(String value, String... importClass) {
if (importClass == null || importClass.length < 1 || importClass[0] == null) {
if (value != null) {
return value.replaceAll("#IMPORT", "");
}
- 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 update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean update(Object value) {
if (value instanceof ObjectCondition == false) {
return false;
}
Method withLine
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public TemplateResultFragment withLine(String value, Class<?>... importClass) {
String[] imports = null;
if (importClass != null) {
imports = new String[importClass.length];
for (int i = 0; i < importClass.length; i++) {
- 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 getText
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
@Override
public String getText(CharSequence label, Object model, Object gui) {
/* Global Variables */
if (this.variables != null) {
String value = variables.getText(label, model, gui);
- 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 (EntityUtil.isDate(itemType) == false) {
continue;
}
Avoid too many return
statements within this method. Open
return item.getValue(item, 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 element.getVariable();
Avoid too many return
statements within this method. Open
return element.getText(attribute, null, null);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return (Integer) last;
Avoid too many return
statements within this method. Open
return item.getValue(attribute.substring(pos + 1));
Avoid too many return
statements within this method. Open
return element;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return item.getValue(attribute.substring(pos + 1));
Avoid too many return
statements within this method. Open
return element.isExpression();
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return this.stack.last();
Avoid too many return
statements within this method. Open
return element.getTemplateModel();
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return item.getValue(item, attribute.substring(pos + 1));
Avoid too many return
statements within this method. Open
return 1;
Avoid too many return
statements within this method. Open
return element.getParent();
Avoid too many return
statements within this method. Open
return element.getMember();
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return item.getValue(item, attribute.substring(pos + 1));
Avoid too many return
statements within this method. Open
return element.getHeaders();
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return value;
Avoid too many return
statements within this method. Open
return element.getKey();
Avoid too many return
statements within this method. Open
return item.getValue(item, attribute.substring(pos + 1));
Avoid too many return
statements within this method. Open
return object.toString();
Avoid too many return
statements within this method. Open
return null;
Method create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static final TemplateResultFragment create(GraphModel model, boolean useImport, boolean createModel) {
TemplateResultFragment fragment = new TemplateResultFragment().withMember(model);
fragment.useImport = useImport;
if (createModel && model != null) {
String classModel = "de.uniks.networkparser.ext.ClassModel";
- 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 (EntityUtil.isDate(itemType) == false) {
continue;
}
- 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
}
}