fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/Style.java

Summary

Maintainability
F
3 days
Test Coverage

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

public class Style implements Cloneable, SendableEntityCreatorNoIndex {
    /** The Constant PROPERTY_NAME for Name of Style */
    public static final String PROPERTY_NAME = "name";
    private String name;

Severity: Minor
Found in src/main/java/de/uniks/networkparser/Style.java - About 4 hrs to fix

    File Style.java has 295 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package de.uniks.networkparser;
    
    /*
    NetworkParser
    The MIT License
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/Style.java - About 3 hrs to fix

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

          @Override
          public boolean setValue(Object entity, String attribute, Object value, String type) {
              if (entity instanceof Style == false) {
                  return false;
              }
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/Style.java - About 2 hrs to fix

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

            @Override
            public Object getValue(Object entity, String attrName) {
                String attribute;
                if (attrName == null || entity instanceof Style == false) {
                    return false;
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/Style.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 getValue has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public Object getValue(Object entity, String attrName) {
                String attribute;
                if (attrName == null || entity instanceof Style == false) {
                    return false;
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/Style.java - About 1 hr to fix

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

              @Override
              public boolean setValue(Object entity, String attribute, Object value, String type) {
                  if (entity instanceof Style == false) {
                      return false;
                  }
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/Style.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 setBorder has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public void setBorder(GUIPosition position, String width, String color) {
                  GUILine border = this.borders.get(position);
                  if (width != null) {
                      if (border == null) {
                          this.borders.put(position, new GUILine().withColor(color).withWidth(width));
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/Style.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

          Avoid too many return statements within this method.
          Open

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

                      Avoid too many return statements within this method.
                      Open

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

                            Avoid too many return statements within this method.
                            Open

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

                                Avoid too many return statements within this method.
                                Open

                                            return style.isUnderline();
                                Severity: Major
                                Found in src/main/java/de/uniks/networkparser/Style.java - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

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

                                      Avoid too many return statements within this method.
                                      Open

                                                  return style.getHeight();
                                      Severity: Major
                                      Found in src/main/java/de/uniks/networkparser/Style.java - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

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

                                            Avoid too many return statements within this method.
                                            Open

                                                        return style.getAlignment();
                                            Severity: Major
                                            Found in src/main/java/de/uniks/networkparser/Style.java - About 30 mins to fix

                                              These nested if statements could be combined
                                              Open

                                                          if (border.isCustomLine() == false) {
                                                              this.borders.remove(position);
                                                              this.propertyChange(PROPERTY_BORDER, null, this.borders);
                                                          }

                                              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