zcommon/src/main/java/org/zkoss/util/Utils.java

Summary

Maintainability
C
1 day
Test Coverage

Method compareVersion has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public static final int compareVersion(int[] v1, int[] v2) {
        for (int j = 0;; ++j) {
            if (j == v1.length) {
                for (; j < v2.length; ++j) {
                    if (v2[j] > 0) return -1;
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/Utils.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 convertSubversion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private static final int convertSubversion(String subver) {
        try {
            return Integer.parseInt(subver);
        } catch (Throwable ex) { //eat
        }
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/Utils.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

Consider simplifying this complex logical expression.
Open

            if ((cc < '0' || cc > '9') && (cc < 'a' || cc > 'z')
            && (cc < 'A' || cc > 'Z'))
                break;
Severity: Major
Found in zcommon/src/main/java/org/zkoss/util/Utils.java - About 40 mins to fix

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

        private static final int nextVerSeparator(String version, int from) {
            for (final int len = version.length(); from < len; ++from) {
                final char cc = version.charAt(from);
                if ((cc < '0' || cc > '9') && (cc < 'a' || cc > 'z')
                && (cc < 'A' || cc > 'Z'))
    Severity: Minor
    Found in zcommon/src/main/java/org/zkoss/util/Utils.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

                        if (v1[j] < 0) return -1;
    Severity: Major
    Found in zcommon/src/main/java/org/zkoss/util/Utils.java - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  if (v1[j] > v2[j]) return 1;
      Severity: Major
      Found in zcommon/src/main/java/org/zkoss/util/Utils.java - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    if (v1[j] < v2[j]) return -1;
        Severity: Major
        Found in zcommon/src/main/java/org/zkoss/util/Utils.java - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

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

            There are no issues that match your filters.

            Category
            Status