fujaba/NetworkParser

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

Summary

Maintainability
F
1 wk
Test Coverage

File TemplateResultFragment.java has 552 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.parser;

/*
The MIT License

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

        @Override
        public Object getValue(Object entity, String attribute) {
            if (entity instanceof TemplateResultFragment == false) {
                return null;
            }

    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 put has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        public String put(String label, Object object) {
            if (label == null) {
                return null;
            }

    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

    TemplateResultFragment has 43 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class TemplateResultFragment
            implements Comparable<TemplateResultFragment>, SendableEntityCreator, ObjectCondition, LocalisationInterface {
        public static final String PROPERTY_PARENT = "parent";
        public static final String PROPERTY_CHILD = "child";
        public static final String PROPERTY_CLONE = "clone";

      Method setValue has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public boolean setValue(Object entity, String attribute, Object value, String type) {
              if (entity instanceof TemplateResultFragment == false) {
                  return false;
              }

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method getValue has 100 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public Object getValue(Object entity, String attribute) {
              if (entity instanceof TemplateResultFragment == false) {
                  return null;
              }

        Method update has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public boolean update(Object value) {
                if (value instanceof ObjectCondition == false) {
                    return false;
                }

        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 setValue has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public boolean setValue(Object entity, String attribute, Object value, String type) {
                if (entity instanceof TemplateResultFragment == false) {
                    return false;
                }

          Method put has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Override
              public String put(String label, Object object) {
                  if (label == null) {
                      return null;
                  }

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

                public String replacing(String value, String... importClass) {
                    if (importClass == null || importClass.length < 1 || importClass[0] == null) {
                        if (value != null) {
                            return value.replaceAll("#IMPORT", "");
                        }

            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 update has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Override
                public boolean update(Object value) {
                    if (value instanceof ObjectCondition == false) {
                        return false;
                    }

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

                  public TemplateResultFragment withLine(String value, Class<?>... importClass) {
                      String[] imports = null;
                      if (importClass != null) {
                          imports = new String[importClass.length];
                          for (int i = 0; i < importClass.length; i++) {
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.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 getText has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  @Override
                  public String getText(CharSequence label, Object model, Object gui) {
                      /* Global Variables */
                      if (this.variables != null) {
                          String value = variables.getText(label, model, gui);
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.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 (EntityUtil.isDate(itemType) == false) {
                                          continue;
                                      }
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.java - About 45 mins to fix

                Avoid too many return statements within this method.
                Open

                                        return item.getValue(item, attribute.substring(pos + 1));
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.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/TemplateResultFragment.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

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

                      Avoid too many return statements within this method.
                      Open

                              return element.getText(attribute, null, null);
                      Severity: Major
                      Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.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/TemplateResultFragment.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/TemplateResultFragment.java - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

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

                              Avoid too many return statements within this method.
                              Open

                                                      return item.getValue(attribute.substring(pos + 1));
                              Severity: Major
                              Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.java - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

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

                                        Avoid too many return statements within this method.
                                        Open

                                                        return item.getValue(attribute.substring(pos + 1));
                                        Severity: Major
                                        Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.java - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                      return element.isExpression();
                                          Severity: Major
                                          Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.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/TemplateResultFragment.java - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                              return this.stack.last();
                                              Severity: Major
                                              Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.java - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                            return element.getTemplateModel();
                                                Severity: Major
                                                Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.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/TemplateResultFragment.java - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                        return item.getValue(item, attribute.substring(pos + 1));
                                                    Severity: Major
                                                    Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.java - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

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

                                                        Avoid too many return statements within this method.
                                                        Open

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

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                      return element.getMember();
                                                          Severity: Major
                                                          Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.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/TemplateResultFragment.java - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                              return item.getValue(item, attribute.substring(pos + 1));
                                                              Severity: Major
                                                              Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.java - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                            return element.getHeaders();
                                                                Severity: Major
                                                                Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.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/TemplateResultFragment.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/TemplateResultFragment.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/TemplateResultFragment.java - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

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

                                                                          Avoid too many return statements within this method.
                                                                          Open

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

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                            return item.getValue(item, attribute.substring(pos + 1));
                                                                            Severity: Major
                                                                            Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.java - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                                  return object.toString();
                                                                              Severity: Major
                                                                              Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.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/TemplateResultFragment.java - About 30 mins to fix

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

                                                                                      public static final TemplateResultFragment create(GraphModel model, boolean useImport, boolean createModel) {
                                                                                          TemplateResultFragment fragment = new TemplateResultFragment().withMember(model);
                                                                                          fragment.useImport = useImport;
                                                                                          if (createModel && model != null) {
                                                                                              String classModel = "de.uniks.networkparser.ext.ClassModel";
                                                                                  Severity: Minor
                                                                                  Found in src/main/java/de/uniks/networkparser/parser/TemplateResultFragment.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 (EntityUtil.isDate(itemType) == false) {
                                                                                                              continue;
                                                                                                          }

                                                                                  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