zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java

Summary

Maintainability
F
5 days
Test Coverage

Method parseAction has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

    private static int parseAction(Context ctx, Node parent, String prefix, int from, int to)
            throws DspException, IOException, XelException {
        //1: which action
        int j = skipWhitespaces(ctx, from + 1, to);
        int k = nextSeparator(ctx, j, to);
Severity: Minor
Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 7 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

File Parser.java has 445 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* Parser.java

    Purpose:
        
    Description:
Severity: Minor
Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 6 hrs to fix

    Method parse0 has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        private static void parse0(Context ctx, Node parent, int from, int to)
                throws DspException, IOException, XelException {
            boolean esc = false;
            final StringBuffer sb = new StringBuffer(512);
            for (int j = from; j < to; ++j) {
    Severity: Minor
    Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 6 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 parseAttrs has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        private static int parseAttrs(Context ctx, Map<String, String> attrs, String actnm, int from, int to)
                throws DspException {
            for (int j, k = from;;) {
                j = skipWhitespaces(ctx, k, to);
                k = nextSeparator(ctx, j, to);
    Severity: Minor
    Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.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 parseControl has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private static int parseControl(Context ctx, Node parent, int from, int to)
                throws DspException, IOException, XelException {
            int j = from + 2;
            if (j + 1 >= to)
                throw new DspException(MWeb.DSP_ACTION_NOT_TERMINATED, new Object[] { null, new Integer(ctx.nLines) });
    Severity: Minor
    Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.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 endOfEL has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        private static int endOfEL(Context ctx, int from, int to) throws DspException {
            for (int j = from + 2;; ++j) {
                if (j >= to)
                    throw new DspException(MWeb.EL_NOT_TERMINATED, new Integer(ctx.nLines));
    
    
    Severity: Minor
    Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.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 parseAction has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static int parseAction(Context ctx, Node parent, String prefix, int from, int to)
                throws DspException, IOException, XelException {
            //1: which action
            int j = skipWhitespaces(ctx, from + 1, to);
            int k = nextSeparator(ctx, j, to);
    Severity: Major
    Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 3 hrs to fix

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

          private static void parse0(Context ctx, Node parent, int from, int to)
                  throws DspException, IOException, XelException {
              boolean esc = false;
              final StringBuffer sb = new StringBuffer(512);
              for (int j = from; j < to; ++j) {
      Severity: Major
      Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 2 hrs to fix

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

            private static int parseControl(Context ctx, Node parent, int from, int to)
                    throws DspException, IOException, XelException {
                int j = from + 2;
                if (j + 1 >= to)
                    throw new DspException(MWeb.DSP_ACTION_NOT_TERMINATED, new Object[] { null, new Integer(ctx.nLines) });
        Severity: Minor
        Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 1 hr to fix

          Method parseAttrs has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static int parseAttrs(Context ctx, Map<String, String> attrs, String actnm, int from, int to)
                      throws DspException {
                  for (int j, k = from;;) {
                      j = skipWhitespaces(ctx, k, to);
                      k = nextSeparator(ctx, j, to);
          Severity: Minor
          Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                        if ((cc < '0' || cc > '9') && (cc < 'a' || cc > 'z') && (cc < 'A' || cc > 'Z') && cc != '_')
                            break;
            Severity: Major
            Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (j + 2 < to && ctx.content.charAt(j + 2) == '{')
                                          ++j; //skip '\\'
              Severity: Major
              Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if (j + 2 < to && ctx.content.charAt(j + 2) == '%')
                                            ++j; //skip '\\'
                Severity: Major
                Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (--depth < 0) {
                                              nestedTo = j;
                                              j = l;
                                              break; //done
                                          }
                  Severity: Major
                  Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 45 mins to fix

                    Method parseAction has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        private static int parseAction(Context ctx, Node parent, String prefix, int from, int to)
                    Severity: Minor
                    Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 35 mins to fix

                      Method parseAttrs has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          private static int parseAttrs(Context ctx, Map<String, String> attrs, String actnm, int from, int to)
                      Severity: Minor
                      Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java - About 35 mins to fix

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

                            private static int nextSeparator(Context ctx, int from, int to) {
                                for (; from < to; ++from) {
                                    final char cc = ctx.content.charAt(from);
                                    if ((cc < '0' || cc > '9') && (cc < 'a' || cc > 'z') && (cc < 'A' || cc > 'Z') && cc != '_')
                                        break;
                        Severity: Minor
                        Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.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

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

                            private static void trim(Node node) {
                                for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
                                    final Object o = it.next();
                                    if (o instanceof TextNode) {
                                        final String s = ((TextNode) o).getText();
                        Severity: Minor
                        Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.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

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

                                private void loadTaglib(String prefix, String uri) throws DspException, IOException {
                                    if (_locator == null)
                                        throw new DspException("Unable to load " + uri + " because locator is not specified");
                        
                                    URL url = uri.indexOf("://") > 0 ? null : _locator.getResource(uri);
                        Severity: Minor
                        Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.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

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

                            private static boolean startsWith(String content, int from, int to, String s) {
                                for (int j = 0, len = s.length();; ++from, ++j) {
                                    if (j >= len)
                                        return true;
                                    if (from >= to || content.charAt(from) != s.charAt(j))
                        Severity: Minor
                        Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.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 4 locations. Consider refactoring.
                        Open

                                    if ((cc < '0' || cc > '9') && (cc < 'a' || cc > 'z') && (cc < 'A' || cc > 'Z') && cc != '_')
                        Severity: Major
                        Found in zweb/src/main/java/org/zkoss/web/servlet/dsp/impl/Parser.java and 3 other locations - About 50 mins to fix
                        zk/src/main/java/org/zkoss/zk/scripting/Interpreters.java on lines 180..180
                        zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.java on lines 139..139
                        zk/src/main/java/org/zkoss/zk/ui/sys/Names.java on lines 57..57

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

                        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