fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/json/JsonTokener.java

Summary

Maintainability
F
1 wk
Test Coverage

File JsonTokener.java has 564 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.json;

import java.util.Collection;
/*
NetworkParser
Severity: Major
Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 1 day to fix

    Method decoding has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

        private Object decoding(Object target, JsonObject jsonObject, MapEntity map) {
            /* JSONArray jsonArray; */
            if (map == null) {
                return null;
            }
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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

    Method parseValue has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        private void parseValue(Object target, String property, Object value, SendableEntityCreator creator,
                MapEntity map) {
            /* FIXME IF STATGEGY IS UPDATE SET NEW VALUE */
            if (map == null) {
                return;
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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 decoding has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        public Object decoding(JsonObject jsonObject, MapEntity map, boolean kid) {
            if (map == null) {
                return null;
            }
            if (jsonObject == null) {
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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 parsingSimpleEntityXML has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        private BaseItem parsingSimpleEntityXML(JsonObject parent, XMLEntity newValue) {
            /* <TAG PARAM>CHILDREN</TAG> */
            if (newValue == null) {
                return null;
            }
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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 decodingSimple has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        public Object decodingSimple(JsonObject jsonObject, Object target, SendableEntityCreator creator) {
            if (jsonObject == null || target == null || creator == null) {
                return null;
            }
            String[] properties = creator.getProperties();
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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 parsingEntity has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        private Entity parsingEntity(Entity entity, Buffer buffer) {
            if (buffer == null || entity == null) {
                return entity;
            }
            String key;
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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 parsingEntity has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private Entity parsingEntity(Entity entity, Buffer buffer) {
            if (buffer == null || entity == null) {
                return entity;
            }
            String key;
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 2 hrs to fix

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

          private EntityList parsingEntity(EntityList entityList, Buffer buffer) {
              /* FIXME REMOVE */
              if (buffer == null) {
                  return null;
              }
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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 parsingSimpleEntityXML has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private BaseItem parsingSimpleEntityXML(JsonObject parent, XMLEntity newValue) {
              /* <TAG PARAM>CHILDREN</TAG> */
              if (newValue == null) {
                  return null;
              }
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 2 hrs to fix

        Method parseEntityProp has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            private void parseEntityProp(JsonObject props, Object propValue, String prop) {
                if (propValue != null) {
                    if (propValue instanceof XMLEntity) {
                        if (props.containsKey(prop)) {
                            Object child = props.get(prop);
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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 decoding has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public Object decoding(JsonObject jsonObject, MapEntity map, boolean kid) {
                if (map == null) {
                    return null;
                }
                if (jsonObject == null) {
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 2 hrs to fix

          Method parseValue has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private void parseValue(Object target, String property, Object value, SendableEntityCreator creator,
                      MapEntity map) {
                  /* FIXME IF STATGEGY IS UPDATE SET NEW VALUE */
                  if (map == null) {
                      return;
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 2 hrs to fix

            Method decoding has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private Object decoding(Object target, JsonObject jsonObject, MapEntity map) {
                    /* JSONArray jsonArray; */
                    if (map == null) {
                        return null;
                    }
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 2 hrs to fix

              Method parsingEntityXML has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  private BaseItem parsingEntityXML(JsonObject parent, SimpleKeyValueList<?, ?> newValue) {
                      if (newValue instanceof XMLEntity) {
                          XMLEntity xmlEntity = (XMLEntity) newValue;
              
                          if (simpleFormat) {
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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 parsingEntity has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private EntityList parsingEntity(EntityList entityList, Buffer buffer) {
                      /* FIXME REMOVE */
                      if (buffer == null) {
                          return null;
                      }
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 1 hr to fix

                Method decodingSimple has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public Object decodingSimple(JsonObject jsonObject, Object target, SendableEntityCreator creator) {
                        if (jsonObject == null || target == null || creator == null) {
                            return null;
                        }
                        String[] properties = creator.getProperties();
                Severity: Minor
                Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 1 hr to fix

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

                      public JsonObject parseEntity(JsonObject parent, SimpleKeyValueList<?, ?> newValue) {
                          if (newValue instanceof XMLEntity) {
                              XMLEntity xmlEntity = (XMLEntity) newValue;
                              parent.put(IdMap.CLASS, xmlEntity.getTag());
                              JsonObject props = new JsonObject();
                  Severity: Minor
                  Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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 nextValue has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      @Override
                      public Object nextValue(Buffer buffer, BaseItem creator, boolean allowQuote, boolean allowDuppleMarks,
                              char stopChar) {
                          if (buffer == null) {
                              return null;
                  Severity: Minor
                  Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 1 hr to fix

                    Method parsingEntityXML has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private BaseItem parsingEntityXML(JsonObject parent, SimpleKeyValueList<?, ?> newValue) {
                            if (newValue instanceof XMLEntity) {
                                XMLEntity xmlEntity = (XMLEntity) newValue;
                    
                                if (simpleFormat) {
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 1 hr to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if (jsonProp.has(property)) {
                                                  Object obj = jsonProp.get(property);
                                                  parseValue(target, property, obj, creator, map);
                                              } else {
                                                  Object defaultValue = creator.getValue(prototype, property);
                      Severity: Major
                      Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 45 mins to fix

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

                            public Object nextValue(Buffer buffer, BaseItem creator, boolean allowQuote, boolean allowDuppleMarks,
                                    char stopChar) {
                        Severity: Minor
                        Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 35 mins to fix

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

                              private void parseValue(Object target, String property, Object value, SendableEntityCreator creator,
                                      MapEntity map) {
                          Severity: Minor
                          Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 35 mins to fix

                            Method nextValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                @Override
                                public Object nextValue(Buffer buffer, BaseItem creator, boolean allowQuote, boolean allowDuppleMarks,
                                        char stopChar) {
                                    if (buffer == null) {
                                        return null;
                            Severity: Minor
                            Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 35 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 null;
                            Severity: Major
                            Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return super.nextValue(buffer, creator, allowQuote, allowDuppleMarks, stopChar);
                              Severity: Major
                              Found in src/main/java/de/uniks/networkparser/json/JsonTokener.java - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return parsingEntity((Entity) parent, buffer);
                                Severity: Major
                                Found in src/main/java/de/uniks/networkparser/json/JsonTokener.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/json/JsonTokener.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/json/JsonTokener.java - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

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

                                        Avoid too many return statements within this method.
                                        Open

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

                                          Avoid too many return statements within this method.
                                          Open

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

                                              FIXME found
                                              Open

                                                      /* FIXME IF STATGEGY IS UPDATE SET NEW VALUE */

                                              FIXME found
                                              Open

                                                      /* FIXME REMOVE */

                                              These nested if statements could be combined
                                              Open

                                                          if (isError(this, "parseToEntity", NetworkParserLog.ERROR_TYP_PARSING, entity)) {
                                                              throw new SimpleException("A JsonObject text must begin with '{' \n" + buffer, 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
                                               }
                                              }

                                              There are no issues that match your filters.

                                              Category
                                              Status