fujaba/NetworkParser

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

Summary

Maintainability
F
1 wk
Test Coverage

Method parsing has a Cognitive Complexity of 101 (exceeds 5 allowed). Consider refactoring.
Open

    @SuppressWarnings("unchecked")
    private void parsing(XMLEntity xmlEntity, SendableEntityCreator entityFactory, Object entityObject, String rootId) {
        if (xmlEntity == null || this.map == null) {
            return;
        }
Severity: Minor
Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 2 days 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 EMFTokener.java has 836 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.xml;

/*
NetworkParser
The MIT License
Severity: Major
Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 2 days to fix

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

        private GraphList decoding(XMLEntity ecore, GraphList model) {
            if (model == null) {
                model = new GraphList();
            }
            if (ecore == null) {
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.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 parsing has 142 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @SuppressWarnings("unchecked")
        private void parsing(XMLEntity xmlEntity, SendableEntityCreator entityFactory, Object entityObject, String rootId) {
            if (xmlEntity == null || this.map == null) {
                return;
            }
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 5 hrs to fix

      Method decodingClassModel has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          private Object decodingClassModel(XMLEntity values, GraphModel model) {
              if (values == null || model == null) {
                  return null;
              }
              SimpleKeyValueList<String, Clazz> items = new SimpleKeyValueList<String, Clazz>();
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.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 104 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private GraphList decoding(XMLEntity ecore, GraphList model) {
              if (model == null) {
                  model = new GraphList();
              }
              if (ecore == null) {
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 4 hrs to fix

        Method getRef has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

            private SimpleList<String> getRef(String value, XMLEntity xmlEntity, SendableEntityCreator rootFactory) {
                if (value == null) {
                    return null;
                }
                SimpleList<String> result = new SimpleList<String>();
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.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

        Method encodeChildren has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            private void encodeChildren(Object entity, XMLEntity parent, MapEntity map) {
                SendableEntityCreator creatorClass = getCreatorClass(entity);
                if (creatorClass == null) {
                    return;
                }
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.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

        Method decode has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            public Object decode(MapEntity map, Buffer buffer, Object root) {
                skipHeader(buffer);
                XMLEntity xmlEntity = new XMLEntity();
                xmlEntity.withValue(buffer);
                if (EPACKAGE.equals(xmlEntity.getTag())) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.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

        Method decode has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public Object decode(MapEntity map, Buffer buffer, Object root) {
                skipHeader(buffer);
                XMLEntity xmlEntity = new XMLEntity();
                xmlEntity.withValue(buffer);
                if (EPACKAGE.equals(xmlEntity.getTag())) {
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 2 hrs to fix

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

              public void encodePackagedElementClass(XMLEntity root, Clazz clazz) {
                  if (clazz == null || root == null) {
                      return;
                  }
                  root.withType("packagedElement");
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.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

          EMFTokener has 21 methods (exceeds 20 allowed). Consider refactoring.
          Open

          public class EMFTokener extends Tokener {
              public static final String ECORE = "ecore";
              public static final String EPACKAGE = "ecore:EPackage";
              public static final String EAttribute = "eAttributes";
              public static final String ECLASS = "eClassifiers";
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 2 hrs to fix

            Method encodeClassModel has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public XMLEntity encodeClassModel(GraphList entity, MapEntity map) {
                    XMLContainer container = new XMLContainer();
                    container.withStandardPrefix();
                    if (entity == null || map == null) {
                        return container;
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.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 decodingClassModel has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private Object decodingClassModel(XMLEntity values, GraphModel model) {
                    if (values == null || model == null) {
                        return null;
                    }
                    SimpleKeyValueList<String, Clazz> items = new SimpleKeyValueList<String, Clazz>();
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 1 hr to fix

              Method encodeChildren has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private void encodeChildren(Object entity, XMLEntity parent, MapEntity map) {
                      SendableEntityCreator creatorClass = getCreatorClass(entity);
                      if (creatorClass == null) {
                          return;
                      }
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 1 hr to fix

                Method encodeClassModel has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public XMLEntity encodeClassModel(GraphList entity, MapEntity map) {
                        XMLContainer container = new XMLContainer();
                        container.withStandardPrefix();
                        if (entity == null || map == null) {
                            return container;
                Severity: Minor
                Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 1 hr to fix

                  Method encodePackagedElementClass has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public void encodePackagedElementClass(XMLEntity root, Clazz clazz) {
                          if (clazz == null || root == null) {
                              return;
                          }
                          root.withType("packagedElement");
                  Severity: Minor
                  Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 1 hr to fix

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

                        private Association getOrCreate(SimpleKeyValueList<String, Association> items, GraphList model, String className,
                                String roleName) {
                            if (items == null) {
                                return null;
                            }
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.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 getRef has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private SimpleList<String> getRef(String value, XMLEntity xmlEntity, SendableEntityCreator rootFactory) {
                            if (value == null) {
                                return null;
                            }
                            SimpleList<String> result = new SimpleList<String>();
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 1 hr to fix

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

                          public void encodeOwnedOperation(XMLEntity root, Method method) {
                              if (root == null || method == null) {
                                  return;
                              }
                              root.withType("ownedOperation");
                      Severity: Minor
                      Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 1 hr to fix

                        Method getOrCreate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private Association getOrCreate(SimpleKeyValueList<String, Association> items, GraphList model, String className,
                                    String roleName) {
                                if (items == null) {
                                    return null;
                                }
                        Severity: Minor
                        Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 1 hr to fix

                          Method encodeOwnedValue has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public void encodeOwnedValue(XMLEntity root, Value value) {
                                  if (root == null || value == null) {
                                      return;
                                  }
                                  if (value instanceof Attribute) {
                          Severity: Minor
                          Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 1 hr to fix

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

                                public String skipHeader(Buffer buffer) {
                                    if (buffer == null) {
                                        return "";
                                    }
                                    boolean skip = false;
                            Severity: Minor
                            Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 1 hr to fix

                              Method skipHeader has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public String skipHeader(Buffer buffer) {
                                      if (buffer == null) {
                                          return "";
                                      }
                                      boolean skip = false;
                              Severity: Minor
                              Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 55 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 (key.equals(assoc.getName())) {
                                                          found = assoc;
                                                          break;
                                                      }
                              Severity: Major
                              Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if (EntityUtil.isEMFType(etyp)) {
                                                            etyp = etyp.substring(1);
                                                        }
                                Severity: Major
                                Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          for (String ref : refs) {
                                                              Association back = new Association(items.get(ref));
                                                              found.with(back);
                                                          }
                                  Severity: Major
                                  Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if (EntityUtil.isPrimitiveType(etyp.toLowerCase())) {
                                                                etyp = etyp.toLowerCase();
                                                            }
                                    Severity: Major
                                    Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                              if (rootCollection != null) {
                                                                  rootCollection.add(object);
                                                              } else {
                                                                  entityFactory.setValue(entityObject, tag, object, "");
                                                              }
                                      Severity: Major
                                      Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 45 mins to fix

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

                                            public void encodeOwnedOperation(XMLEntity root, Method method) {
                                                if (root == null || method == null) {
                                                    return;
                                                }
                                                root.withType("ownedOperation");
                                        Severity: Minor
                                        Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.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 (referenceChild.size() > 0) {
                                                                    referenceChild.add(' ');
                                                                }
                                        Severity: Major
                                        Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                                  if (entityObject instanceof Collection<?>) {
                                                                      rootCollection = (Collection<Object>) entityObject;
                                                                  }
                                          Severity: Major
                                          Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 45 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

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

                                              Avoid too many return statements within this method.
                                              Open

                                                          return decodingClassModel(xmlEntity, model);
                                              Severity: Major
                                              Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.java - About 30 mins to fix

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

                                                    public void encodeOwnedValue(XMLEntity root, Value value) {
                                                        if (root == null || value == null) {
                                                            return;
                                                        }
                                                        if (value instanceof Attribute) {
                                                Severity: Minor
                                                Found in src/main/java/de/uniks/networkparser/xml/EMFTokener.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

                                                TODO found
                                                Open

                                                        /* TODO CREATING METHOD BODY */

                                                These nested if statements could be combined
                                                Open

                                                                    if (((Number) upperValue).intValue() != 1) {
                                                                        tgtAssoc.with(Association.MANY);
                                                                    }

                                                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