fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/ext/ModelGenerator.java

Summary

Maintainability
F
6 days
Test Coverage

File ModelGenerator.java has 526 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.ext;

import java.io.File;
/*
The MIT License
Severity: Major
Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 1 day to fix

    Method getTemplates has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        private SimpleList<Template> getTemplates(String filter, SimpleList<Template> owner) {
            if (filter == null) {
                return this.getChildren();
            }
            if (filter.equals(".") || filter.isEmpty()) {
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 6 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 generating has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        public SendableEntityCreator generating(String rootDir, GraphModel model, TextItems parameters, String type,
                boolean writeFiles, boolean enableParser) {
            if(model == null) {
                return null;
            }
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.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 removeAndGenerate has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        public void removeAndGenerate(String... param) {
            String type = null;
            String rootDir = null;
            if (this.defaultModel != null) {
                if (param != null) {
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.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

    ModelGenerator has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class ModelGenerator extends SimpleGenerator {
        private FeatureSet features = Feature.createAll();
        private GraphModel defaultModel;
        private boolean useSDMLibParser = true;
        private String defaultRootDir;
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 4 hrs to fix

      Method generating has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public SendableEntityCreator generating(String rootDir, GraphModel model, TextItems parameters, String type,
                  boolean writeFiles, boolean enableParser) {
              if(model == null) {
                  return null;
              }
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 3 hrs to fix

        Method getTemplates has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private SimpleList<Template> getTemplates(String filter, SimpleList<Template> owner) {
                if (filter == null) {
                    return this.getChildren();
                }
                if (filter.equals(".") || filter.isEmpty()) {
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 2 hrs to fix

          Method getFeature has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              @Override
              public Feature getFeature(Feature value, Clazz... clazzes) {
                  if (this.features != null) {
                      for (Iterator<Feature> i = this.features.iterator(); i.hasNext();) {
                          Feature item = i.next();
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.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 removeAndGenerate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public void removeAndGenerate(String... param) {
                  String type = null;
                  String rootDir = null;
                  if (this.defaultModel != null) {
                      if (param != null) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 1 hr to fix

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

                public boolean write(String rootPath, TemplateResultFile entity) {
                    if(rootPath == null || entity == null) {
                        return false;
                    }
                    if (rootPath.endsWith("/") == false) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.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 parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public ParserEntity parse(String rootPath, TemplateResultFile entity) {
                    /* check for each clazz, if a matching file already exists */
                    if (entity == null || entity.getMember() instanceof Clazz == false) {
                        return null;
                    }
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.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 findClazz has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public Clazz findClazz(String name, boolean defaultValue) {
                    if(defaultModel == null) {
                        return null;
                    }
                    Clazz clazz = (Clazz) this.defaultModel.getChildByName(name, Clazz.class);
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 1 hr to fix

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

                  public Clazz findClazz(String name, boolean defaultValue) {
                      if(defaultModel == null) {
                          return null;
                      }
                      Clazz clazz = (Clazz) this.defaultModel.getChildByName(name, Clazz.class);
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.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

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

                  public Association findAssociation(Clazz clazz, String name, boolean defaultValue) {
                      if (name == null || clazz == null) {
                          if (defaultValue) {
                              return new Association(null);
                          }
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.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 (TYPE_JAVA.equalsIgnoreCase(param[0]) || TYPE_TYPESCRIPT.equalsIgnoreCase(param[0])
                                              || TYPE_CPP.equalsIgnoreCase(param[0])) {
                                          type = param[0];
                                      } else if (param.length < 2) {
                                          rootDir = param[0];
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 45 mins to fix

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

                    public Attribute findAttribute(Clazz clazz, String name, boolean defaultValue) {
                        if (name == null || clazz == null) {
                            if (defaultValue) {
                                return new Attribute("", DataType.VOID);
                            }
                Severity: Minor
                Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.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

                Method generating has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public SendableEntityCreator generating(String rootDir, GraphModel model, TextItems parameters, String type,
                            boolean writeFiles, boolean enableParser) {
                Severity: Minor
                Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 45 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return null;
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return new Clazz("");
                    Severity: Major
                    Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

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

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

                                public boolean remove(GraphModel model, String rootDir, String type) {
                                    if(rootDir == null || model == null) {
                                        return false;
                                    }
                                    /*
                            Severity: Minor
                            Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.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 addTemplate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public boolean addTemplate(Template template, boolean addOwner) {
                                    if (super.addTemplate(template, addOwner) == false) {
                                        return false;
                                    }
                                    String id2 = template.getId(true);
                            Severity: Minor
                            Found in src/main/java/de/uniks/networkparser/ext/ModelGenerator.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

                            These nested if statements could be combined
                            Open

                                                if (param[1] instanceof String) {
                                                    rootDir = param[1];
                                                }

                            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 (filter.startsWith(childId)) {
                                                    String sub = filter.substring(childId.length());
                                                    /* Sub must be start with poitn or empty */
                                                    if (sub.isEmpty() || sub.startsWith(".")) {
                                                        result.addAll(getTemplates(sub, child.getChildren()));

                            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 (param[0] instanceof String) {
                                                    if (TYPE_JAVA.equalsIgnoreCase(param[0]) || TYPE_TYPESCRIPT.equalsIgnoreCase(param[0])
                                                            || TYPE_CPP.equalsIgnoreCase(param[0])) {
                                                        type = param[0];
                                                    } else if (param.length < 2) {

                            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