File Space.java
has 945 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext.petaf;
import java.util.Collection;
import de.uniks.networkparser.DateTimeEntity;
Space
has 92 methods (exceeds 20 allowed). Consider refactoring. Open
public class Space extends SendableItem implements ObjectCondition, SendableEntityCreator {
private final String[] properties = new String[] { Space.PROPERTY_NAME, Space.PROPERTY_PATH, Space.PROPERTY_HISTORY,
Space.PROPERTY_PROXY };
public static final String PROPERTY_MODELROOT = "root";
public static final String PROPERTY_HISTORY = "history";
Method calculateSendProxy
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
protected void calculateSendProxy(Message msg, NodeProxy receiver, SimpleSet<NodeProxy> sendProxies) {
SimpleSet<NodeProxy> received = msg.getReceived();
SimpleList<Integer> receiverProxy = new SimpleList<Integer>();
NodeProxy proxy;
- 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 createModel
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public NodeProxyFileSystem createModel(Object root, String fileName) {
createModel(root);
NodeProxyFileSystem fileSystem = null;
if (fileName != null) {
String filePath = 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 sendMessage
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public boolean sendMessage(Message msg, boolean sendAnyhow, NodeProxy... proxies) {
if (msg == null) {
return false;
}
if (msg.sending(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
Method calculateSendProxy
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void calculateSendProxy(Message msg, NodeProxy receiver, SimpleSet<NodeProxy> sendProxies) {
SimpleSet<NodeProxy> received = msg.getReceived();
SimpleList<Integer> receiverProxy = new SimpleList<Integer>();
NodeProxy proxy;
Method createModel
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public NodeProxyFileSystem createModel(Object root, String fileName) {
createModel(root);
NodeProxyFileSystem fileSystem = null;
if (fileName != null) {
String filePath = null;
Method sendMessage
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean sendMessage(Message msg, boolean sendAnyhow, NodeProxy... proxies) {
if (msg == null) {
return false;
}
if (msg.sending(this)) {
Method with
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public Space with(NodeProxy... values) {
if (values == null) {
return this;
}
for (NodeProxy proxy : values) {
- 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 startModelDistribution
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public boolean startModelDistribution(boolean alwaysEncode) {
IdMap map = getMap();
boolean result = true;
for (NodeProxy proxy : this.proxies) {
if (proxy instanceof NodeProxyModel) {
- 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 getMyNode
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public NodeProxy getMyNode() {
if (this.myNode == null) {
NodeProxy last = null;
for (NodeProxy item : proxies) {
if (NodeProxy.isInput(item.getType())) {
- 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 getModel
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public NodeProxyModel getModel() {
if (this.myModel == null) {
NodeProxyModel last = null;
for (NodeProxy item : proxies) {
if (item instanceof NodeProxyModel) {
- 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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean update(Object value) {
if (value instanceof SimpleEvent == 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 updateModel
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public boolean updateModel(SimpleEvent event) {
if (this.isInit == false) {
return false;
}
if (SendableEntityCreator.UPDATE.equals(event.getType()) || SendableEntityCreator.NEW.equals(event.getType())) {
- 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 getNodeProxies
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public SortedSet<NodeProxy> getNodeProxies(ObjectCondition... filters) {
if (filters == null) {
return proxies;
}
SortedSet<NodeProxy> result = new SortedSet<NodeProxy>(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
Method setReplicationInfo
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public boolean setReplicationInfo(Buffer msg) {
Tokener tokener = getTokener();
Entity result = tokener.newInstance();
result.withValue(msg);
Object value = result.getValue(PROPERTY_PROXY);
- 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 (sendProxies.add(proxy) == false) {
/* Break while */
step = this.peerCount;
}
Method sendMessageToPeers
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public boolean sendMessageToPeers(Message msg, NodeProxy receiver) {
boolean success = false;
addInfo(msg, receiver, false);
/* inform the next n peers */
SimpleSet<NodeProxy> sendProxies = new SimpleSet<NodeProxy>();
- 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 createModel
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public NodeProxyModel createModel(Object root) {
/* Check if NodeProxyModel exists for root */
NodeProxyModel model = getModel();
if (root == null) {
return 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 true;
Avoid too many return
statements within this method. Open
return space.getHistory();
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return updateModel(event);
Avoid too many return
statements within this method. Open
return isInit;
Avoid too many return
statements within this method. Open
return null;
Method getLastProxy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public NodeProxy getLastProxy(String property) {
NodeProxy lastItem = null;
long max = Long.MIN_VALUE;
for (NodeProxy item : proxies) {
Object value = item.getValue(item, property);
- 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 (received.indexOf(proxy) < 0 || proxy instanceof NodeProxyFileSystem) {
step++;
if (sendProxies.add(proxy) == false) {
/* Break while */
step = this.peerCount;
- 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
}
}
Do not hard code the IP address Open
if (url.equals("127.0.0.1")) {
- Read upRead up
- Exclude checks
AvoidUsingHardCodedIP
Since: PMD 4.1
Priority: Medium
Categories: Style
Remediation Points: 50000
Application with hard-coded IP addresses can become impossible to deploy in some cases. Externalizing IP adresses is preferable.
Example:
public class Foo {
private String ip = '127.0.0.1'; // not recommended
}
These nested if statements could be combined Open
if (getMap().encode(model, tokener) == null) {
result = 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
}
}