zcommon/src/main/java/org/zkoss/idom/Verifier.java

Summary

Maintainability
F
1 wk
Test Coverage

File Verifier.java has 362 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* Verifier.java


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

    Method checkCharacterData has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        public static final void checkCharacterData(String text, Locator loc) {
            if (text == null)
                throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
                    "A null is not a legal XML value", loc);
    
    
    Severity: Minor
    Found in zcommon/src/main/java/org/zkoss/idom/Verifier.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 isXMLExtender has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        public static boolean isXMLExtender(final char c) {
            /*
             * This function is not accellerated by the bitmask system because
             * there are no longer any actual calls to it from the JDOM code.
             * It used to be called by the isXMLNameCharacter() method before
    Severity: Minor
    Found in zcommon/src/main/java/org/zkoss/idom/Verifier.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 checkNamespacePrefix has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        public static final void checkNamespacePrefix(String prefix, Locator loc) {
            if (prefix == null || prefix.length() == 0)
                return; //OK: null or empty
    
            String reason = null;
    Severity: Minor
    Found in zcommon/src/main/java/org/zkoss/idom/Verifier.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 checkCharacterData has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static final void checkCharacterData(String text, Locator loc) {
            if (text == null)
                throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
                    "A null is not a legal XML value", loc);
    
    
    Severity: Minor
    Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 1 hr to fix

      Method checkNamespacePrefix has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static final void checkNamespacePrefix(String prefix, Locator loc) {
              if (prefix == null || prefix.length() == 0)
                  return; //OK: null or empty
      
              String reason = null;
      Severity: Minor
      Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                if (c < 0x309D) return false;  if (c <= 0x309E) return true;
        Severity: Major
        Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return false;
          Severity: Major
          Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    if (c == 0x0387) return true;
            Severity: Major
            Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      if (c == 0x0640) return true;
              Severity: Major
              Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        if (c < 0x3031) return false;  if (c <= 0x3035) return true;
                Severity: Major
                Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          if (c < 0x309D) return false;  if (c <= 0x309E) return true;
                  Severity: Major
                  Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            if (c < 0x30FC) return false;  if (c <= 0x30FE) return true;
                    Severity: Major
                    Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              if (c == 0x3005) return true;
                      Severity: Major
                      Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                if (c == 0x0EC6) return true;
                        Severity: Major
                        Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  if (c < 0x30FC) return false;  if (c <= 0x30FE) return true;
                          Severity: Major
                          Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    if (c == 0x0E46) return true;
                            Severity: Major
                            Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      if (c < 0x3031) return false;  if (c <= 0x3035) return true;
                              Severity: Major
                              Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 30 mins to fix

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

                                    public static final void checkNamespaceURI(String uri, Locator loc) {
                                        if (uri == null || uri.length() == 0)
                                            return; //OK: null or empty
                                
                                        String reason = null;
                                Severity: Minor
                                Found in zcommon/src/main/java/org/zkoss/idom/Verifier.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

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

                                    public static void checkXMLName(String name, Locator loc) {
                                        if (name == null || name.length() == 0)
                                            throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
                                                "XML names cannot be null or empty", loc);
                                
                                
                                Severity: Minor
                                Found in zcommon/src/main/java/org/zkoss/idom/Verifier.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

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

                                    private static final byte[] VALCONST = new byte[] {
                                        0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x41, 0x01, 
                                        0x41, 0x49, 0x41, 0x59, 0x41, 0x01, 0x41, 0x01, 
                                        0x41, 0x4f, 0x01, 0x4d, 0x01, 0x4f, 0x01, 0x41, 
                                        0x01, 0x09, 0x01, 0x0f, 0x01, 0x0f, 0x01, 0x0f, 
                                Severity: Major
                                Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java and 1 other location - About 2 days to fix
                                zcommon/src/main/java/org/zkoss/idom/Verifier.java on lines 177..255

                                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 1254.

                                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 static final int [] LENCONST = new int [] {
                                        9,     2,     2,     1,    18,     1,     1,     2, 
                                        9,     2,     1,    10,     1,     2,     1,     1, 
                                        2,    26,     4,     1,     1,    26,     3,     1, 
                                       56,     1,     8,    23,     1,    31,     1,    58, 
                                Severity: Major
                                Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java and 1 other location - About 2 days to fix
                                zcommon/src/main/java/org/zkoss/idom/Verifier.java on lines 94..172

                                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 1254.

                                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