fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/ext/petaf/Space.java

Summary

Maintainability
F
1 wk
Test Coverage

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;
Severity: Major
Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 2 days to fix

    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";
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 1 day to fix

      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;
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 1 day to fix

      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;
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 5 hrs to fix

      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)) {
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 3 hrs to fix

      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;
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 2 hrs to fix

        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;
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 1 hr to fix

          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)) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 1 hr to fix

            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) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 1 hr to fix

            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) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 1 hr to fix

            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())) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 1 hr to fix

            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) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 1 hr to fix

            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;
                    }
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 55 mins to fix

            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())) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 45 mins to fix

            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);
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 45 mins to fix

            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);
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 45 mins to fix

            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;
                                    }
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 45 mins to fix

              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>();
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 45 mins to fix

              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;
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 35 mins to fix

              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;
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return space.getHistory();
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return true;
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return updateModel(event);
                    Severity: Major
                    Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return isInit;
                      Severity: Major
                      Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return null;
                        Severity: Major
                        Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 30 mins to fix

                          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);
                          Severity: Minor
                          Found in src/main/java/de/uniks/networkparser/ext/petaf/Space.java - About 25 mins to fix

                          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;

                          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")) {

                          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;
                                              }

                          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
                           }
                          }

                          There are no issues that match your filters.

                          Category
                          Status