Method convertToAdvanced
has a Cognitive Complexity of 165 (exceeds 5 allowed). Consider refactoring. Open
public TemplateResultFragment convertToAdvanced(TemplateResultFragment fragment) {
if (fragment == null) {
return null;
}
GraphModel model = (GraphModel) fragment.getMember();
- 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 convertFromJson
has a Cognitive Complexity of 154 (exceeds 5 allowed). Consider refactoring. Open
public GraphModel convertFromJson(Entity model, GraphModel reference) {
if (model == null || model.has(NODES) == false) {
return null;
}
EntityList nodes = (EntityList) model.getValue(NODES);
- 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 GraphConverter.java
has 1057 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.converter;
/*
NetworkParser
The MIT License
Method parseJsonObject
has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring. Open
public Clazz parseJsonObject(GraphList root, Entity node) {
if (root == null || node == null) {
return null;
}
String id = node.getString("id");
- 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 convertToAdvanced
has 197 lines of code (exceeds 25 allowed). Consider refactoring. Open
public TemplateResultFragment convertToAdvanced(TemplateResultFragment fragment) {
if (fragment == null) {
return null;
}
GraphModel model = (GraphModel) fragment.getMember();
Method convertFromJson
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
public GraphModel convertFromJson(Entity model, GraphModel reference) {
if (model == null || model.has(NODES) == false) {
return null;
}
EntityList nodes = (EntityList) model.getValue(NODES);
Method createMember
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private void createMember(TemplateResultFragment fragment, GraphMember member,
SimpleKeyValueList<GraphMember, String> names, ModifierSet refModifier) {
if (member instanceof Association) {
Association assoc = (Association) member;
String name = (String) names.getValue(assoc.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
Method parseJsonObject
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Clazz parseJsonObject(GraphList root, Entity node) {
if (root == null || node == null) {
return null;
}
String id = node.getString("id");
Method convertToMetaText
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public TemplateResultFragment convertToMetaText(GraphModel model, boolean full, boolean useImport) {
TemplateResultFragment fragment = TemplateResultFragment.create(model, useImport, true);
if (full == false || model == null) {
return convertToAdvanced(fragment);
}
- 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
GraphConverter
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
public class GraphConverter implements Converter {
public static final String TYPE = "type";
public static final String ID = "id";
public static final String NODE = "node";
Method convertToMetaText
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public TemplateResultFragment convertToMetaText(GraphModel model, boolean full, boolean useImport) {
TemplateResultFragment fragment = TemplateResultFragment.create(model, useImport, true);
if (full == false || model == null) {
return convertToAdvanced(fragment);
}
Method createMember
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void createMember(TemplateResultFragment fragment, GraphMember member,
SimpleKeyValueList<GraphMember, String> names, ModifierSet refModifier) {
if (member instanceof Association) {
Association assoc = (Association) member;
String name = (String) names.getValue(assoc.getClazz());
Method parseMethods
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private EntityList parseMethods(GraphEntity list, boolean shortName, boolean removeParameterNames) {
EntityList result = (EntityList) factory.getNewList(false);
GraphSimpleSet children = GraphUtil.getChildren(list);
if (children == null) {
return result;
- 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 parseEntity
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public Entity parseEntity(String type, GraphMember entity, boolean shortName, boolean removeParameterNames) {
if (type == null) {
type = GraphTokener.OBJECTDIAGRAM;
if (entity == null || entity.getName() == null) {
type = GraphTokener.CLASSDIAGRAM;
- 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 parseEdge
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private Entity parseEdge(String type, Clazz source, Clazz target, Association edge, boolean shortName,
ArrayList<String> ids) {
Entity child = (Entity) factory.getNewList(true);
if (ids == null || edge == null || type == null || source == null || target == null) {
return child;
- 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 parseEdge
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Entity parseEdge(String type, Clazz source, Clazz target, Association edge, boolean shortName,
ArrayList<String> ids) {
Entity child = (Entity) factory.getNewList(true);
if (ids == null || edge == null || type == null || source == null || target == null) {
return child;
Method convertToTestCode
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public TemplateResultFragment convertToTestCode(GraphModel model, boolean createModel) {
TemplateResultFragment code = new TemplateResultFragment();
if (model == null) {
return code;
}
- 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 parseEntities
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public EntityList parseEntities(String type, GraphEntity nodes, boolean shortName, boolean removeParameterNames) {
EntityList result = (EntityList) factory.getNewList(false);
ArrayList<String> ids = new ArrayList<String>();
GraphSimpleSet children = GraphUtil.getChildren(nodes);
if (children == 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 parseEntity
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Entity parseEntity(String type, GraphMember entity, boolean shortName, boolean removeParameterNames) {
if (type == null) {
type = GraphTokener.OBJECTDIAGRAM;
if (entity == null || entity.getName() == null) {
type = GraphTokener.CLASSDIAGRAM;
Method parseEdges
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private EntityList parseEdges(String type, SimpleSet<Association> edges, boolean shortName) {
EntityList result = (EntityList) factory.getNewList(false);
if (edges == null) {
return result;
}
- 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 parseAttributes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private EntityList parseAttributes(String type, GraphEntity list, boolean shortName) {
EntityList result = (EntityList) factory.getNewList(false);
String splitter = "";
if (GraphTokener.OBJECTDIAGRAM.equals(type)) {
splitter = "=";
- 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 parseMethods
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private EntityList parseMethods(GraphEntity list, boolean shortName, boolean removeParameterNames) {
EntityList result = (EntityList) factory.getNewList(false);
GraphSimpleSet children = GraphUtil.getChildren(list);
if (children == null) {
return result;
Method convertToJson
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Entity convertToJson(GraphModel root, boolean removePackage, boolean removeParameterNames) {
if (root == null) {
return null;
}
String type = GraphTokener.CLASSDIAGRAM;
Method parseAttributes
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private EntityList parseAttributes(String type, GraphEntity list, boolean shortName) {
EntityList result = (EntityList) factory.getNewList(false);
String splitter = "";
if (GraphTokener.OBJECTDIAGRAM.equals(type)) {
splitter = "=";
Method convertToTestCode
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public TemplateResultFragment convertToTestCode(GraphModel model, boolean createModel) {
TemplateResultFragment code = new TemplateResultFragment();
if (model == null) {
return code;
}
Method getFreeName
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private String getFreeName(SimpleKeyValueList<GraphMember, String> names, GraphMember member) {
if (names == null || member == null) {
return null;
}
String value = member.getName().toLowerCase();
Method convertToJson
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public Entity convertToJson(GraphModel root, boolean removePackage, boolean removeParameterNames) {
if (root == null) {
return null;
}
String type = GraphTokener.CLASSDIAGRAM;
- 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 getFreeName
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private String getFreeName(SimpleKeyValueList<GraphMember, String> names, GraphMember member) {
if (names == null || member == null) {
return null;
}
String value = member.getName().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
Method parseEdge
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private Entity parseEdge(String type, GraphEntity source, GraphEntity target, Association edge, boolean shortName,
ArrayList<String> ids) {
Method parseEdge
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private Entity parseEdge(String type, Clazz source, Clazz target, Association edge, boolean shortName,
ArrayList<String> ids) {
Method parseEdge
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private Entity parseEdge(String type, GraphPattern source, GraphPattern target, Association edge, boolean shortName,
ArrayList<String> ids) {
Avoid deeply nested control flow statements. Open
if (entity instanceof String) {
} else if (entity instanceof Entity) {
Entity json = (Entity) entity;
if (json.has(ID)) {
Method method = clazz.createMethod(json.getString(ID));
Avoid deeply nested control flow statements. Open
if (oldValue == null) {
String key = (String) names.getValue(newValue);
if (key != null) {
fragment.withLineString(matchNameMatch + ".withSuperClazz(\"" + key + "\");");
} else {
Avoid deeply nested control flow statements. Open
if (entity instanceof String) {
String attribute = (String) entity;
int pos = attribute.indexOf(":");
if (pos > 0) {
clazz.createAttribute(attribute.substring(0, pos),
Method parseGraphEntity
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private void parseGraphEntity(GraphEntity entity, Entity item, String type, boolean shortName,
boolean removeParameterNames) {
Method encode
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
@Override
public String encode(BaseItem entity) {
if (entity instanceof GraphModel) {
GraphModel model = (GraphModel) entity;
GraphSimpleSet children = GraphUtil.getChildren(model);
- 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 null;
Avoid too many return
statements within this method. Open
return null;
Method addInfo
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private Entity addInfo(Association edge, boolean cardinality, boolean property) {
Entity result = (Entity) factory.getNewList(true);
if (edge == null) {
return result;
}
- 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 getNodeHeader
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public GraphCustomItem getNodeHeader(GraphEntity entity) {
GraphSimpleSet children = GraphUtil.getChildren(entity);
if (children != null) {
for (GraphMember member : children) {
if (member instanceof GraphCustomItem) {
- 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 parseEdge
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private Entity parseEdge(String type, GraphEntity source, GraphEntity target, Association edge, boolean shortName,
ArrayList<String> ids) {
if (source instanceof Clazz && target instanceof Clazz) {
return parseEdge(type, (Clazz) source, (Clazz) target, edge, shortName, ids);
}
- 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
FIXME found Open
/* FIXME FOR ASSOC -- ATTRIBUTE */
- Exclude checks
These nested if statements could be combined Open
if (newValue instanceof DataType == false) {
newValue = fragment.replacing("#IMPORT.create(\"" + newValue + "\")",
DataType.class.getName());
}
- 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
}
}