fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/xml/XMLEntity.java

Summary

Maintainability
F
4 days
Test Coverage

Method getElementsBy has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

    public EntityList getElementsBy(String key, String value) {
        if (value == null) {
            return null;
        }
        EntityList children = getNewList(false);
Severity: Minor
Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.java - About 7 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 XMLEntity.java has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.xml;

/*
NetworkParser
The MIT License
Severity: Minor
Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.java - About 5 hrs to fix

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

    public class XMLEntity extends SimpleKeyValueList<String, Object> implements Entity, EntityList {
        /** Constant of TAG. */
        public static final String PROPERTY_TAG = "tag";
        /** Constant of VALUE. */
        public static final String PROPERTY_VALUE = "value";
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.java - About 3 hrs to fix

      Method getElementsBy has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public EntityList getElementsBy(String key, String value) {
              if (value == null) {
                  return null;
              }
              EntityList children = getNewList(false);
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.java - About 2 hrs to fix

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

            public String getValue() {
                if (this.valueItem == null && this.sizeChildren() > 0) {
                    /* Complex children */
                    boolean show = false;
                    for (int i = 0; i < this.children.size(); i++) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.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 toStringChildren has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            protected void toStringChildren(CharacterBuffer sb, EntityStringConverter converter) {
                /* parse Children */
                if (sb == null) {
                    return;
                }
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.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 getElementBy has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public Entity getElementBy(String key, String value) {
                if (value == null) {
                    return null;
                }
                if (value.equalsIgnoreCase(getString(key))) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.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 getElementBy has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public Entity getElementBy(String key, String value) {
                if (value == null) {
                    return null;
                }
                if (value.equalsIgnoreCase(getString(key))) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.java - About 1 hr to fix

          Method toStringChildren has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected void toStringChildren(CharacterBuffer sb, EntityStringConverter converter) {
                  /* parse Children */
                  if (sb == null) {
                      return;
                  }
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.java - About 1 hr to fix

            Method add has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                @Override
                public boolean add(Object... values) {
                    if (values == null || values.length < 1) {
                        return false;
                    }
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.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 withValue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public XMLEntity withValue(Tokener tokener, Object values) {
                    if (tokener != null) {
                        Buffer buffer = null;
                        if (values instanceof Buffer) {
                            buffer = (Buffer) values;
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.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 getValue has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public String getValue() {
                    if (this.valueItem == null && this.sizeChildren() > 0) {
                        /* Complex children */
                        boolean show = false;
                        for (int i = 0; i < this.children.size(); i++) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/xml/XMLEntity.java - About 1 hr to fix

              Avoid too many return statements within this method.
              Open

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

                    Avoid too many return statements within this method.
                    Open

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

                      Avoid too many return statements within this method.
                      Open

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

                        These nested if statements could be combined
                        Open

                                    if (value.equalsIgnoreCase(this.getValue())) {
                                        return this;
                                    }

                        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 (value.equalsIgnoreCase(this.getTag())) {
                                        return this;
                                    }

                        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 (((XMLEntity) item).getTag() == null) {
                                                show = true;
                                                break;
                                            }

                        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