fujaba/NetworkParser

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

Summary

Maintainability
F
3 days
Test Coverage

File DateTimeEntity.java has 452 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser;

import java.util.Date;

/*
Severity: Minor
Found in src/main/java/de/uniks/networkparser/DateTimeEntity.java - About 6 hrs to fix

    DateTimeEntity has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class DateTimeEntity implements SendableEntityCreatorNoIndex {
        public static final String W3CDTF_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
        private boolean dirty;
        private Long time;
        private Byte timeZone = 1;
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/DateTimeEntity.java - About 5 hrs to fix

      Method internCalculate has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          private boolean internCalculate(long time, boolean calc) {
              long years = time / ONE_YEAR + 1970;
              long schaltjahre = ((years - 1) - 1968) / 4 - ((years - 1) - 1900) / 100 + ((years - 1) - 1600) / 400;
              long yearMillis = (time - (schaltjahre - 1) * ONE_DAY) % ONE_YEAR;
              int year = (int) ((time - schaltjahre * ONE_DAY) / ONE_YEAR) + 1970;
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/DateTimeEntity.java - About 4 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 internCalculate has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private boolean internCalculate(long time, boolean calc) {
              long years = time / ONE_YEAR + 1970;
              long schaltjahre = ((years - 1) - 1968) / 4 - ((years - 1) - 1900) / 100 + ((years - 1) - 1600) / 400;
              long yearMillis = (time - (schaltjahre - 1) * ONE_DAY) % ONE_YEAR;
              int year = (int) ((time - schaltjahre * ONE_DAY) / ONE_YEAR) + 1970;
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/DateTimeEntity.java - About 2 hrs to fix

        Method toString has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public String toString(String format) {
                initDate();
                calculate();
                CharacterBuffer sb = new CharacterBuffer();
                String sub;
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/DateTimeEntity.java - About 2 hrs to fix

        Cognitive Complexity

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

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

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

        Further reading

        Method toString has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public String toString(String format) {
                initDate();
                calculate();
                CharacterBuffer sb = new CharacterBuffer();
                String sub;
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/DateTimeEntity.java - About 2 hrs to fix

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

              public long getValueInMillisecond(String field) {
                  if (fields == null || field == null) {
                      return 0;
                  }
                  Object result = fields.get(field);
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/DateTimeEntity.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 getValueInMillisecond has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public long getValueInMillisecond(String field) {
                  if (fields == null || field == null) {
                      return 0;
                  }
                  Object result = fields.get(field);
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/DateTimeEntity.java - About 1 hr to fix

            Avoid too many return statements within this method.
            Open

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

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

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

                      Avoid too many return statements within this method.
                      Open

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

                          Avoid too many return statements within this method.
                          Open

                                      return value * (DateTimeEntity.ONE_DAY / 2);
                          Severity: Major
                          Found in src/main/java/de/uniks/networkparser/DateTimeEntity.java - About 30 mins to fix

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

                                private void initDate() {
                                    if (items != null && !isInitConstants) {
                                        /* Month */
                                        for (int i = 0; i < 12; i++) {
                                            monthOfYear[i] = items.getText(monthOfYear[i], this, null);
                            Severity: Minor
                            Found in src/main/java/de/uniks/networkparser/DateTimeEntity.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

                            FIXME found
                            Open

                                        /* FIXME Change String to StringContainter */

                            These nested if statements could be combined
                            Open

                                            if ((7 - dayOfWeek) < leftDays) {
                                                return true;
                                            }

                            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