zul/src/main/java/org/zkoss/zul/SimpleConstraint.java

Summary

Maintainability
F
1 wk
Test Coverage

Method parseCst has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
Open

    private void parseCst(String constraint) {
        String regex = null, errmsg = null, regexFlags = "";
        l_out:
        for (int j = 0, k = 0, len = constraint.length(); k >= 0; j = k + 1) {
            for (; ; ++j) {
Severity: Minor
Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 1 day 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 validate has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

    public void validate(Component comp, Object value) throws WrongValueException {
        if (!_finishParseCst) {
            if (_raw != null) parseCst(_raw);
            _finishParseCst = true;
        }
Severity: Minor
Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 1 day 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 SimpleConstraint.java has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* SimpleConstraint.java

    Purpose:
        
    Description:
Severity: Minor
Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 4 hrs to fix

    Method parseConstraint has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        protected int parseConstraint(String constraint) throws UiException {
            if (constraint.equals("no positive"))
                return NO_POSITIVE;
            else if (constraint.equals("no negative"))
                return NO_NEGATIVE;
    Severity: Minor
    Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 3 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 parseCst has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private void parseCst(String constraint) {
            String regex = null, errmsg = null, regexFlags = "";
            l_out:
            for (int j = 0, k = 0, len = constraint.length(); k >= 0; j = k + 1) {
                for (; ; ++j) {
    Severity: Major
    Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 2 hrs to fix

      Method validate has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public void validate(Component comp, Object value) throws WrongValueException {
              if (!_finishParseCst) {
                  if (_raw != null) parseCst(_raw);
                  _finishParseCst = true;
              }
      Severity: Major
      Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 2 hrs to fix

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

            protected int parseConstraint(String constraint) throws UiException {
                if (constraint.equals("no positive"))
                    return NO_POSITIVE;
                else if (constraint.equals("no negative"))
                    return NO_NEGATIVE;
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 1 hr to fix

          Method getClientConstraint has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public String getClientConstraint() {
                  if (_raw != null)
                      return '\'' + Strings.escape(_raw, Strings.ESCAPE_JAVASCRIPT) + '\'';
          
                  final StringBuffer sb = new StringBuffer("new zul.inp.SimpleConstraint(");
          Severity: Minor
          Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.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 getRegex has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              private Pattern getRegex(String regex, String regexFlags) {
                  if (regex == null || regex.length() == 0)
                      return null;
                  if (regexFlags.length() == 0) {
                      return Pattern.compile(regex);
          Severity: Minor
          Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.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 deeply nested control flow statements.
          Open

                                      if (k >= len) { //no ending /
                                          k = -1;
                                          break;
                                      }
          Severity: Major
          Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if (matcher.find()) {
                                            regexFlags = matcher.group(0).trim();
                                        }
            Severity: Major
            Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if (cc == '/') {
                                              hasEndingSlash = true;
                                              break; //ending / found
                                          }
              Severity: Major
              Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if (cc == '\\')
                                                ++k; //skip one
                Severity: Major
                Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 45 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return START_AFTER;
                  Severity: Major
                  Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return END_BEFORE;
                    Severity: Major
                    Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return NO_FUTURE;
                      Severity: Major
                      Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return AFTER_START;
                        Severity: Major
                        Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return NO_ZERO;
                          Severity: Major
                          Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return BEFORE_START;
                            Severity: Major
                            Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return SERVER;
                              Severity: Major
                              Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return STRICT;
                                Severity: Major
                                Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return START_BEFORE;
                                  Severity: Major
                                  Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return NO_NEGATIVE;
                                    Severity: Major
                                    Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return NO_POSITIVE;
                                      Severity: Major
                                      Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                return 0;
                                        Severity: Major
                                        Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                      return NO_TODAY;
                                          Severity: Major
                                          Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                        return OVERLAP_END;
                                            Severity: Major
                                            Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                          return AFTER_END;
                                              Severity: Major
                                              Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                            return NO_PAST;
                                                Severity: Major
                                                Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                              return OVERLAP;
                                                  Severity: Major
                                                  Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                return END_AFTER;
                                                    Severity: Major
                                                    Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                  return BEFORE_END;
                                                      Severity: Major
                                                      Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                    return NO_EMPTY;
                                                        Severity: Major
                                                        Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java - About 30 mins to fix

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              private int getMessageForNumberDenied() {
                                                                  switch (_flags & (NO_POSITIVE | NO_NEGATIVE | NO_ZERO)) {
                                                                  case (NO_POSITIVE | NO_ZERO):
                                                                      return MZul.NO_POSITIVE_ZERO;
                                                                  case (NO_POSITIVE):
                                                          Severity: Major
                                                          Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java and 1 other location - About 2 hrs to fix
                                                          zul/src/main/java/org/zkoss/zul/SimpleConstraint.java on lines 444..462

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 129.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              private int getMessageForDateDenied() {
                                                                  switch (_flags & (NO_FUTURE | NO_PAST | NO_TODAY)) {
                                                                  case (NO_FUTURE | NO_TODAY):
                                                                      return MZul.NO_FUTURE_TODAY;
                                                                  case (NO_FUTURE):
                                                          Severity: Major
                                                          Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java and 1 other location - About 2 hrs to fix
                                                          zul/src/main/java/org/zkoss/zul/SimpleConstraint.java on lines 424..442

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 129.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                      if (cmp > 0) {
                                                                          if ((_flags & NO_FUTURE) != 0)
                                                                              throw wrongValue(comp, getMessageForDateDenied());
                                                                      } else if (cmp == 0) {
                                                                          if ((_flags & NO_TODAY) != 0)
                                                          Severity: Major
                                                          Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java and 1 other location - About 1 hr to fix
                                                          zul/src/main/java/org/zkoss/zul/SimpleConstraint.java on lines 371..380

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 88.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                      if (cmp > 0) {
                                                                          if ((_flags & NO_POSITIVE) != 0)
                                                                              throw wrongValue(comp, getMessageForNumberDenied());
                                                                      } else if (cmp == 0) {
                                                                          if ((_flags & NO_ZERO) != 0)
                                                          Severity: Major
                                                          Found in zul/src/main/java/org/zkoss/zul/SimpleConstraint.java and 1 other location - About 1 hr to fix
                                                          zul/src/main/java/org/zkoss/zul/SimpleConstraint.java on lines 402..411

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 88.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          There are no issues that match your filters.

                                                          Category
                                                          Status