File ModelGenerator.java
has 526 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext;
import java.io.File;
/*
The MIT License
Method getTemplates
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
private SimpleList<Template> getTemplates(String filter, SimpleList<Template> owner) {
if (filter == null) {
return this.getChildren();
}
if (filter.equals(".") || filter.isEmpty()) {
- 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 generating
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public SendableEntityCreator generating(String rootDir, GraphModel model, TextItems parameters, String type,
boolean writeFiles, boolean enableParser) {
if(model == 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 removeAndGenerate
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
public void removeAndGenerate(String... param) {
String type = null;
String rootDir = null;
if (this.defaultModel != null) {
if (param != 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
ModelGenerator
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
public class ModelGenerator extends SimpleGenerator {
private FeatureSet features = Feature.createAll();
private GraphModel defaultModel;
private boolean useSDMLibParser = true;
private String defaultRootDir;
Method generating
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
public SendableEntityCreator generating(String rootDir, GraphModel model, TextItems parameters, String type,
boolean writeFiles, boolean enableParser) {
if(model == null) {
return null;
}
Method getTemplates
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private SimpleList<Template> getTemplates(String filter, SimpleList<Template> owner) {
if (filter == null) {
return this.getChildren();
}
if (filter.equals(".") || filter.isEmpty()) {
Method getFeature
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
@Override
public Feature getFeature(Feature value, Clazz... clazzes) {
if (this.features != null) {
for (Iterator<Feature> i = this.features.iterator(); i.hasNext();) {
Feature item = i.next();
- 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 removeAndGenerate
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void removeAndGenerate(String... param) {
String type = null;
String rootDir = null;
if (this.defaultModel != null) {
if (param != null) {
Method write
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public boolean write(String rootPath, TemplateResultFile entity) {
if(rootPath == null || entity == null) {
return false;
}
if (rootPath.endsWith("/") == 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 parse
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public ParserEntity parse(String rootPath, TemplateResultFile entity) {
/* check for each clazz, if a matching file already exists */
if (entity == null || entity.getMember() instanceof Clazz == 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 findClazz
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Clazz findClazz(String name, boolean defaultValue) {
if(defaultModel == null) {
return null;
}
Clazz clazz = (Clazz) this.defaultModel.getChildByName(name, Clazz.class);
Method findClazz
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public Clazz findClazz(String name, boolean defaultValue) {
if(defaultModel == null) {
return null;
}
Clazz clazz = (Clazz) this.defaultModel.getChildByName(name, Clazz.class);
- 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 findAssociation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public Association findAssociation(Clazz clazz, String name, boolean defaultValue) {
if (name == null || clazz == null) {
if (defaultValue) {
return new Association(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
Avoid deeply nested control flow statements. Open
if (TYPE_JAVA.equalsIgnoreCase(param[0]) || TYPE_TYPESCRIPT.equalsIgnoreCase(param[0])
|| TYPE_CPP.equalsIgnoreCase(param[0])) {
type = param[0];
} else if (param.length < 2) {
rootDir = param[0];
Method findAttribute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public Attribute findAttribute(Clazz clazz, String name, boolean defaultValue) {
if (name == null || clazz == null) {
if (defaultValue) {
return new Attribute("", DataType.VOID);
}
- 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 generating
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public SendableEntityCreator generating(String rootDir, GraphModel model, TextItems parameters, String type,
boolean writeFiles, boolean enableParser) {
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return new Clazz("");
Avoid too many return
statements within this method. Open
return clazz;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
Method remove
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public boolean remove(GraphModel model, String rootDir, String type) {
if(rootDir == null || model == 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 addTemplate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public boolean addTemplate(Template template, boolean addOwner) {
if (super.addTemplate(template, addOwner) == false) {
return false;
}
String id2 = template.getId(true);
- 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 (param[1] instanceof String) {
rootDir = param[1];
}
- 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 (filter.startsWith(childId)) {
String sub = filter.substring(childId.length());
/* Sub must be start with poitn or empty */
if (sub.isEmpty() || sub.startsWith(".")) {
result.addAll(getTemplates(sub, child.getChildren()));
- 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 (param[0] instanceof String) {
if (TYPE_JAVA.equalsIgnoreCase(param[0]) || TYPE_TYPESCRIPT.equalsIgnoreCase(param[0])
|| TYPE_CPP.equalsIgnoreCase(param[0])) {
type = param[0];
} else if (param.length < 2) {
- 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
}
}