fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/UpdateCondition.java

Summary

Maintainability
F
1 wk
Test Coverage

Method update has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public boolean update(Object evt) {
        if (isAtomar()) {
            if (evt instanceof PropertyChangeEvent) {
                return condition.update(evt);
Severity: Minor
Found in src/main/java/de/uniks/networkparser/UpdateCondition.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

File UpdateCondition.java has 421 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser;

import java.beans.PropertyChangeEvent;

import de.uniks.networkparser.interfaces.Entity;
Severity: Minor
Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 6 hrs to fix

    Method mergeChanges has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        public Object mergeChanges() {
            if (this.changes == null) {
                return null;
            }
            Entity mergeChange = null;
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/UpdateCondition.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 changeItem has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public boolean changeItem(Object source, Object target, String property) {
            if (map == null) {
                return false;
            }
            SendableEntityCreator creator = map.getCreatorClass(source);
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/UpdateCondition.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 changeAttribute has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        private boolean changeAttribute(Object target, Object newValue, String property, SendableEntityCreator creator,
                Object defaultItem) {
            if (creator == null) {
                return false;
            }
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/UpdateCondition.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 update has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        public boolean update(Object evt) {
            if (isAtomar()) {
                if (evt instanceof PropertyChangeEvent) {
                    return condition.update(evt);
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 3 hrs to fix

      UpdateCondition has 29 methods (exceeds 20 allowed). Consider refactoring.
      Open

      public class UpdateCondition implements ObjectCondition {
          private Object owner;
          private ObjectCondition condition; /* FOR ATOM OR TRANSACTION */
      
          /** FOR ACCUMULATE */
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 3 hrs to fix

        Method changeItem has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public boolean changeItem(Object source, Object target, String property) {
                if (map == null) {
                    return false;
                }
                SendableEntityCreator creator = map.getCreatorClass(source);
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 2 hrs to fix

          Method changeAttribute has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private boolean changeAttribute(Object target, Object newValue, String property, SendableEntityCreator creator,
                      Object defaultItem) {
                  if (creator == null) {
                      return false;
                  }
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 2 hrs to fix

            Method mergeChanges has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public Object mergeChanges() {
                    if (this.changes == null) {
                        return null;
                    }
                    Entity mergeChange = null;
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 1 hr to fix

              Method changeAttribute has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public boolean changeAttribute(UpdateListener listener, Object source, SendableEntityCreator creator,
                          String property, Object oldValue, Object newValue) {
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                if (mergeUpdate != null) {
                                                    mergeUpdate.put(valueKey, valueValue);
                                                }
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 45 mins to fix

                  Method addChange has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      private void addChange(UpdateListener listener, Object source, SendableEntityCreator creator, String property,
                              Object oldValue, Object newValue) {
                  Severity: Minor
                  Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (source.getClass() == endClass) {
                                                if (this.condition != null) {
                                                    return this.condition.update(this.changes);
                                                }
                                                this.changes = null;
                    Severity: Major
                    Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 45 mins to fix

                      Method changeAttribute has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          private boolean changeAttribute(Object target, Object newValue, String property, SendableEntityCreator creator,
                                  Object defaultItem) {
                      Severity: Minor
                      Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 35 mins to fix

                        Avoid too many return statements within this method.
                        Open

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

                              Avoid too many return statements within this method.
                              Open

                                                              return this.condition.update(this.changes);
                              Severity: Major
                              Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return map.getKey(event.getModelValue()) == null && map.getKey(event.getNewValue()) == null;
                                Severity: Major
                                Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

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

                                      Avoid too many return statements within this method.
                                      Open

                                                                      return this.condition.update(this.changes);
                                      Severity: Major
                                      Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                        return false;
                                        Severity: Major
                                        Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                                          return this.condition.update(eventTransaction);
                                          Severity: Major
                                          Found in src/main/java/de/uniks/networkparser/UpdateCondition.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/UpdateCondition.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/UpdateCondition.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/UpdateCondition.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/UpdateCondition.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/UpdateCondition.java - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                              return false;
                                                      Severity: Major
                                                      Found in src/main/java/de/uniks/networkparser/UpdateCondition.java - About 30 mins to fix

                                                        These nested if statements could be combined
                                                        Open

                                                                            if (source.getClass() == owner) {
                                                                                this.changes = new SimpleSet<SimpleEvent>();
                                                                                return true;
                                                                            }

                                                        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