fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/list/EntityComparator.java

Summary

Maintainability
D
1 day
Test Coverage

Method checkValues has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    @SuppressWarnings("unchecked")
    private int checkValues(Object v1, Object v2) {
        if (v1 instanceof String) {
            String valueA = (String) v1;
            if (v2 != null) {
Severity: Minor
Found in src/main/java/de/uniks/networkparser/list/EntityComparator.java - About 4 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 checkValues has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @SuppressWarnings("unchecked")
    private int checkValues(Object v1, Object v2) {
        if (v1 instanceof String) {
            String valueA = (String) v1;
            if (v2 != null) {
Severity: Major
Found in src/main/java/de/uniks/networkparser/list/EntityComparator.java - About 2 hrs to fix

    Method checkIntern has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private int checkIntern(Object o1, Object o2) {
            /* SAME OBJECT MUST BE 0 */
            if (o2 == null) {
                if (o1 == null) {
                    return 0;
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/list/EntityComparator.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 compareValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public int compareValue(Object o1, Object o2) {
            if (VALUES.equals(column)) {
                return checkValues(o1, o2);
            }
            if (map != null) {
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/list/EntityComparator.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 too many return statements within this method.
    Open

                return v1.compareTo(v2);
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/list/EntityComparator.java - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

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

        Avoid too many return statements within this method.
        Open

                    return owner.indexOf(o1) - owner.indexOf(o2);
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/list/EntityComparator.java - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return ((Comparable<Object>) v2).compareTo(v1);
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/list/EntityComparator.java - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return checkValues(v2, v1) * -1;
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/list/EntityComparator.java - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

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

                    Avoid too many return statements within this method.
                    Open

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

                      Avoid too many return statements within this method.
                      Open

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

                        Avoid too many return statements within this method.
                        Open

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

                          Avoid too many return statements within this method.
                          Open

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

                            Avoid too many return statements within this method.
                            Open

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

                              These nested if statements could be combined
                              Open

                                          if (v2 instanceof Comparable<?>) {
                                              return ((Comparable<Object>) v2).compareTo(v1);
                                          }

                              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