fujaba/NetworkParser

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

Summary

Maintainability
F
5 days
Test Coverage

Method setValueItem has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
Open

    @SuppressWarnings("unchecked")
    public SimpleKeyValueList<K, V> setValueItem(Object key, Object value) {
        int pos = indexOf(key);
        if (pos >= 0) {
            this.setValue(pos, (V) value);
Severity: Minor
Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.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 SimpleKeyValueList.java has 537 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.list;

/*
NetworkParser
The MIT License
Severity: Major
Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.java - About 1 day to fix

    SimpleKeyValueList has 49 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class SimpleKeyValueList<K, V> extends AbstractArray<K> implements Map<K, V>, Iterable<Entry<K, V>> {
        private Comparator<Object> cpr;
    
        public SimpleKeyValueList() {
            super();
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.java - About 6 hrs to fix

      Method setValueItem has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @SuppressWarnings("unchecked")
          public SimpleKeyValueList<K, V> setValueItem(Object key, Object value) {
              int pos = indexOf(key);
              if (pos >= 0) {
                  this.setValue(pos, (V) value);
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.java - About 3 hrs to fix

        Method replaceAllValues has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public void replaceAllValues(Object key, String search, String replace) {
                if (key == null) {
                    return;
                }
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.java - About 2 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 withKeyValueString has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public SimpleKeyValueList<K, V> withKeyValueString(String keyValue, Class<?> valueType) {
                int pos = 0, start;
                String key, value;
                char item;
                do {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.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 increment has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public SimpleKeyValueList<K, V> increment(K key) {
                Object value = this.get(key);
                if (value == null) {
                    setValueItem(key, 1);
                    return this;
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.java - About 1 hr to fix

          Method increment has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public SimpleKeyValueList<K, V> increment(K key) {
                  Object value = this.get(key);
                  if (value == null) {
                      setValueItem(key, 1);
                      return this;
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.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 withKeyValueString has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public SimpleKeyValueList<K, V> withKeyValueString(String keyValue, Class<?> valueType) {
                  int pos = 0, start;
                  String key, value;
                  char item;
                  do {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.java - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (list.size() >= id) {
                                        if (value == null) {
                                            list.remove(id);
                                        } else {
                                            list.set(id, value);
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (id == -2) {
                                          id = list.size() - 1;
                                      }
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.java - About 45 mins to fix

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

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

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

                        public SimpleKeyValueList<K, V> addToKeyValue(Object key, Number value) {
                            int pos = hasKeyAndPos(key);
                            if (pos < 0) {
                                return this;
                            }
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.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

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

                        public boolean getBoolean(K key) throws SimpleException {
                            Object value = get(key);
                    
                            if (Boolean.FALSE.equals(value) || (value instanceof String && "false".equalsIgnoreCase((String) value))) {
                                return false;
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/list/SimpleKeyValueList.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

                    Ensure you override both equals() and hashCode()
                    Open

                        public boolean equals(Object obj) {

                    OverrideBothEqualsAndHashcode

                    Since: PMD 0.4

                    Priority: Medium

                    Categories: Style

                    Remediation Points: 50000

                    Override both public boolean Object.equals(Object other), and public int Object.hashCode(), or override neither. Even if you are inheriting a hashCode() from a parent class, consider implementing hashCode and explicitly delegating to your superclass.

                    Example:

                    public class Bar { // poor, missing a hashcode() method
                     public boolean equals(Object o) {
                     // do some comparison
                     }
                    }
                    
                    public class Baz { // poor, missing an equals() method
                     public int hashCode() {
                     // return some hash value
                     }
                    }
                    
                    public class Foo { // perfect, both methods provided
                     public boolean equals(Object other) {
                     // do some comparison
                     }
                     public int hashCode() {
                     // return some hash value
                     }
                    }

                    There are no issues that match your filters.

                    Category
                    Status