fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/parser/Template.java

Summary

Maintainability
F
1 wk
Test Coverage

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

    public ObjectCondition parsing(CharacterBuffer buffer, LocalisationInterface customTemplate, boolean isExpression,
            boolean allowSpace, String... stopWords) {
        if (buffer == null) {
            return null;
        }
Severity: Minor
Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 3 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 Template.java has 687 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.parser;

/*
The MIT License

Severity: Major
Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 1 day to fix

    Method parsing has 222 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public ObjectCondition parsing(CharacterBuffer buffer, LocalisationInterface customTemplate, boolean isExpression,
                boolean allowSpace, String... stopWords) {
            if (buffer == null) {
                return null;
            }
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 1 day to fix

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

          protected void executeChildren(Clazz clazz, LocalisationInterface parameters, SimpleList<Template> templates,
                  String id2, TemplateResultFile templateResult) {
              // FIRST ATTRIBUTE
              AttributeSet attributes = clazz.getAttributes();
              if (attributes.size() > 0) {
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/parser/Template.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

      Template has 38 methods (exceeds 20 allowed). Consider refactoring.
      Open

      public class Template implements TemplateParser {
          public static final String PROPERTY_FEATURE = "features";
          public static final String TYPE_JAVA = "java";
          public static final String TYPE_TYPESCRIPT = "typescript";
          public static final String TYPE_CPP = "cpp";
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 5 hrs to fix

        Method executeChildren has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected void executeChildren(Clazz clazz, LocalisationInterface parameters, SimpleList<Template> templates,
                    String id2, TemplateResultFile templateResult) {
                // FIRST ATTRIBUTE
                AttributeSet attributes = clazz.getAttributes();
                if (attributes.size() > 0) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 1 hr to fix

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

              protected boolean isValid(TemplateItem member, LocalisationInterface parameters) {
                  if (member == null) {
                      return false;
                  }
                  if (isValid) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/parser/Template.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 generate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public TemplateResultFragment generate(LocalisationInterface parameters, SendableEntityCreator parent,
                      TemplateItem member) {
                  ObjectCondition condition = this.token.getCondition();
                  if (condition instanceof StringCondition) {
                      this.token.withCondition(this.parsing((StringCondition) condition, parameters, false));
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 1 hr to fix

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

                public ObjectCondition parsing(ParserCondition... customTemplates) {
                    TemplateResultModel result = new TemplateResultModel();
                    SimpleList<ParserCondition> templateCondition = getTemplateCondition();
                    if (templateCondition != null) {
                        for (ParserCondition condition : templateCondition) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/parser/Template.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 withTemplate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public Template withTemplate(String... template) {
                    CharacterBuffer sb = new CharacterBuffer();
                    if (template == null || template.length < 1) {
                        setValue(sb);
                        return this;
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/parser/Template.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 (tokenPart.equalsIgnoreCase(stopword)) {
                                        buffer.withPosition(startCommand);
                                        if (parent.size() == 1) {
                                            return parent.first();
                                        }
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (buffer.getCurrentChar() == ' ') {
                                          buffer.skip();
                                      }
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if (nextChar == ENTER) {
                                            this.lastStopWords = stopWords;
                                            Equals equalsExpression = new Equals();
                                            equalsExpression.create(buffer, this, customTemplate);
                                            equalsExpression.withLeft(child);
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (token.equalsIgnoreCase(stopword)) {
                                              return parent;
                                          }
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (item instanceof ParserCondition) {
                                                condition = (ParserCondition) item;
                                            }
                    Severity: Major
                    Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if (assoc.getClazz().equals(assoc.getOtherClazz())
                                                      && assoc.getName().equals(assoc.getOther().getName()) == false) {
                                                  template.executeTemplate(parameters, templateResult, assoc.getOther());
                                              }
                      Severity: Major
                      Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 45 mins to fix

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

                            protected void executeChildren(Clazz clazz, LocalisationInterface parameters, SimpleList<Template> templates,
                                    String id2, TemplateResultFile templateResult) {
                        Severity: Minor
                        Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 35 mins to fix

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

                              public ObjectCondition parsing(CharacterBuffer buffer, LocalisationInterface customTemplate, boolean isExpression,
                                      boolean allowSpace, String... stopWords) {
                          Severity: Minor
                          Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 35 mins to fix

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

                                public void executeTemplate(LocalisationInterface parameters, TemplateResultFile templateResult,
                                        GraphMember member) {
                                    if (isValid(member, parameters) == false) {
                                        return;
                                    }
                            Severity: Minor
                            Found in src/main/java/de/uniks/networkparser/parser/Template.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 StringCondition.create(buffer.substring(start, end + 1));
                            Severity: Major
                            Found in src/main/java/de/uniks/networkparser/parser/Template.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/parser/Template.java - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return parent;
                                Severity: Major
                                Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return parent.first();
                                  Severity: Major
                                  Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return false;
                                    Severity: Major
                                    Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return child;
                                      Severity: Major
                                      Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return true;
                                        Severity: Major
                                        Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                                      return parent;
                                          Severity: Major
                                          Found in src/main/java/de/uniks/networkparser/parser/Template.java - About 30 mins to fix

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

                                                private TemplateResultFragment executingEntity(ObjectCondition condition, Object parameters) {
                                                    this.isValid = true;
                                            
                                                    TemplateResultFragment templateFragment = new TemplateResultFragment();
                                                    templateFragment.withKey(this.getType());
                                            Severity: Minor
                                            Found in src/main/java/de/uniks/networkparser/parser/Template.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 getId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public String getId(boolean full) {
                                                    if (full == false) {
                                                        return id;
                                                    }
                                                    if (this.owner != null) {
                                            Severity: Minor
                                            Found in src/main/java/de/uniks/networkparser/parser/Template.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 executeClazz has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public TemplateResultFile executeClazz(Clazz clazz, LocalisationInterface parameters, boolean isStandard) {
                                                    if (isValid(clazz, parameters) == false) {
                                                        return null;
                                                    }
                                                    TemplateResultFile templateResult = createResultFile(clazz, isStandard);
                                            Severity: Minor
                                            Found in src/main/java/de/uniks/networkparser/parser/Template.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 (buffer.getCurrentChar() == ' ') {
                                                                        buffer.skip();
                                                                    }

                                            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 (stopCharacter.indexOf(character) >= 0) {
                                                                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