fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/logic/Equals.java

Summary

Maintainability
F
4 days
Test Coverage

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

    @Override
    public boolean update(Object evt) {
        if (evt == null) {
            return value == null;
        }
Severity: Minor
Found in src/main/java/de/uniks/networkparser/logic/Equals.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 update has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    public boolean update(Object evt) {
        if (evt == null) {
            return value == null;
        }
Severity: Major
Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 3 hrs to fix

    Method getValue has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private Object getValue(ObjectCondition condition, Object evt) {
            if (evt instanceof LocalisationInterface) {
                LocalisationInterface li = (LocalisationInterface) evt;
                if (condition instanceof ParserCondition) {
                    return ((ParserCondition) condition).getValue(li);
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/logic/Equals.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

    File Equals.java has 312 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package de.uniks.networkparser.logic;
    
    import java.beans.PropertyChangeEvent;
    import java.util.Set;
    
    
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 3 hrs to fix

      Equals has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

      public class Equals implements ParserCondition, SendableEntityCreator {
          /** Constant of KEY. */
          public static final String PROPERTY_KEY = "key";
      
          /** Constant of StrValue. */
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 2 hrs to fix

        Method getValue has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private Object getValue(ObjectCondition condition, Object evt) {
                if (evt instanceof LocalisationInterface) {
                    LocalisationInterface li = (LocalisationInterface) evt;
                    if (condition instanceof ParserCondition) {
                        return ((ParserCondition) condition).getValue(li);
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 1 hr to fix

          Method create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              @Override
              public void create(CharacterBuffer buffer, TemplateParser parser, LocalisationInterface customTemplate) {
                  /* CHECK IF CURRENT = */
                  if(buffer == null || parser ==  null) {
                      return;
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/logic/Equals.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 (position > 0) {
                                      return rightNumber > leftNumber;
                                  }
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 45 mins to fix

            Avoid too many return statements within this method.
            Open

                        return value.equals(evt);
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return event.getPropertyName().equals(value);
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/logic/Equals.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/logic/Equals.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return leftValue.equals(rightValue);
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return ((AssociationTypes) leftValue).IsSame(rightValue);
                    Severity: Major
                    Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return ((AssociationTypes) rightValue).IsSame(rightValue);
                      Severity: Major
                      Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return evt == null;
                        Severity: Major
                        Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              return ((expValue - deltaValue) <= evtValue && (expValue + deltaValue) >= evtValue);
                          Severity: Major
                          Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return expValue.equals(evtValue);
                            Severity: Major
                            Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                      return value == evt;
                              Severity: Major
                              Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return ((ParserCondition) condition).getValue(li);
                                Severity: Major
                                Found in src/main/java/de/uniks/networkparser/logic/Equals.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/logic/Equals.java - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                    return ((String) leftValue).equalsIgnoreCase((String) rightValue);
                                    Severity: Major
                                    Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                          return this.value.equals(item);
                                      Severity: Major
                                      Found in src/main/java/de/uniks/networkparser/logic/Equals.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/logic/Equals.java - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                          return value.equals(this.value);
                                          Severity: Major
                                          Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                        return buffer.byteAt(pos) == btrValue;
                                            Severity: Major
                                            Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                          return oc.update(event);
                                              Severity: Major
                                              Found in src/main/java/de/uniks/networkparser/logic/Equals.java - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                    return ((expValue - deltaValue) <= evtValue && (expValue + deltaValue) >= evtValue);
                                                Severity: Major
                                                Found in src/main/java/de/uniks/networkparser/logic/Equals.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/logic/Equals.java - About 30 mins to fix

                                                    Method getValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        @Override
                                                        public Object getValue(LocalisationInterface value) {
                                                            if (value instanceof SendableEntityCreator) {
                                                                SendableEntityCreator variables = (SendableEntityCreator) value;
                                                                Object object = variables.getValue(variables, this.key);
                                                    Severity: Minor
                                                    Found in src/main/java/de/uniks/networkparser/logic/Equals.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 (leftValue instanceof Number || EntityUtil.isNumeric("" + leftValue)) {
                                                                        if (rightValue instanceof Number || EntityUtil.isNumeric("" + rightValue)) {
                                                                            Double leftNumber = Double.valueOf("" + leftValue);
                                                                            Double rightNumber = Double.valueOf("" + rightValue);
                                                                            if (position > 0) {

                                                    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 (rightValue instanceof Number || EntityUtil.isNumeric("" + rightValue)) {
                                                                            Double leftNumber = Double.valueOf("" + leftValue);
                                                                            Double rightNumber = Double.valueOf("" + rightValue);
                                                                            if (position > 0) {
                                                                                return rightNumber > leftNumber;

                                                    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