zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java

Summary

Maintainability
F
1 wk
Test Coverage

Method unescape has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
Open

    static String unescape(final String text) {

        if (text == null) {
            return null;
        }
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.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 unescape has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
Open

    static void unescape(final char[] text, final int offset, final int len, final Writer writer)
                         throws IOException {

        if (text == null) {
            return;
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.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 JavaScriptEscapeUtil.java has 494 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * =============================================================================
 * 
 *   Copyright (c) 2014, The UNBESCAPE team (http://www.unbescape.org)
 * 
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 7 hrs to fix

    Method escape has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        static String escape(final String text,
                             final JavaScriptEscapeType escapeType, final JavaScriptEscapeLevel escapeLevel) {
    
            if (text == null) {
                return null;
    Severity: Minor
    Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 5 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 escape has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        static void escape(final char[] text, final int offset, final int len, final Writer writer,
                           final JavaScriptEscapeType escapeType, final JavaScriptEscapeLevel escapeLevel)
                           throws IOException {
    
            if (text == null || text.length == 0) {
    Severity: Minor
    Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.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 unescape has 106 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static String unescape(final String text) {
    
            if (text == null) {
                return null;
            }
    Severity: Major
    Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 4 hrs to fix

      Method unescape has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static void unescape(final char[] text, final int offset, final int len, final Writer writer)
                               throws IOException {
      
              if (text == null) {
                  return;
      Severity: Major
      Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 3 hrs to fix

        Method escape has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static String escape(final String text,
                                 final JavaScriptEscapeType escapeType, final JavaScriptEscapeLevel escapeLevel) {
        
                if (text == null) {
                    return null;
        Severity: Major
        Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 2 hrs to fix

          Method escape has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static void escape(final char[] text, final int offset, final int len, final Writer writer,
                                 final JavaScriptEscapeType escapeType, final JavaScriptEscapeLevel escapeLevel)
                                 throws IOException {
          
                  if (text == null || text.length == 0) {
          Severity: Major
          Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 2 hrs to fix

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

                static boolean isOctalEscape(final char[] text, final int start, final int end) {
            
                    if (start >= end) {
                        return false;
                    }
            Severity: Minor
            Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.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 isOctalEscape has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                static boolean isOctalEscape(final String text, final int start, final int end) {
            
                    if (start >= end) {
                        return false;
                    }
            Severity: Minor
            Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.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 ((f - (i + 2)) < 2) {
                                        // We weren't able to consume the required two hexa chars, leave it as slash+'x', which
                                        // is invalid, and let the corresponding JavaScript engine fail.
                                        i++;
                                        continue;
            Severity: Major
            Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 45 mins to fix

              Method escape has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  static void escape(final char[] text, final int offset, final int len, final Writer writer,
                                     final JavaScriptEscapeType escapeType, final JavaScriptEscapeLevel escapeLevel)
              Severity: Minor
              Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if ((f - (i + 2)) < 2) {
                                            // We weren't able to consume the required two hexa chars, leave it as slash+'x', which
                                            // is invalid, and let the corresponding JavaScript engine fail.
                                            i++;
                                            continue;
                Severity: Major
                Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          while (f < (i + 4) && f < max) {
                                              final char cf = text.charAt(f);
                                              if (!((cf >= '0' && cf <= '9') || (cf >= 'A' && cf <= 'F') || (cf >= 'a' && cf <= 'f'))) {
                                                  break;
                                              }
                  Severity: Major
                  Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            while (f < (i + 4) && f < max) {
                                                final char cf = text[f];
                                                if (!((cf >= '0' && cf <= '9') || (cf >= 'A' && cf <= 'F') || (cf >= 'a' && cf <= 'f'))) {
                                                    break;
                                                }
                    Severity: Major
                    Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 45 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                                                  if (!((cf >= '0' && cf <= '9') || (cf >= 'A' && cf <= 'F') || (cf >= 'a' && cf <= 'f'))) {
                                                      break;
                                                  }
                      Severity: Major
                      Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                                    if (!((cf >= '0' && cf <= '9') || (cf >= 'A' && cf <= 'F') || (cf >= 'a' && cf <= 'f'))) {
                                                        break;
                                                    }
                        Severity: Major
                        Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                              } else if (c1 == '8' || c1 == '9' || c1 == '\n' || c1 == '\r' || c1 == '\u2028' || c1 == '\u2029') {
                          
                                                  // '8' and '9' are not valid octal escape sequences, and the other four characters
                                                  // are LineTerminators, which are not allowed as escape sequences. So we leave it as is
                                                  // and expect the corresponding JavaScript engine to fail (except in the case of slash + '\n',
                          Severity: Major
                          Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                                } else if (c1 == '8' || c1 == '9' || c1 == '\n' || c1 == '\r' || c1 == '\u2028' || c1 == '\u2029') {
                            
                                                    // '8' and '9' are not valid octal escape sequences, and the other four characters
                                                    // are LineTerminators, which are not allowed as escape sequences. So we leave it as is
                                                    // and expect the corresponding JavaScript engine to fail (except in the case of slash + '\n',
                            Severity: Major
                            Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                                          if (!((cf >= '0' && cf <= '9') || (cf >= 'A' && cf <= 'F') || (cf >= 'a' && cf <= 'f'))) {
                                                              break;
                                                          }
                              Severity: Major
                              Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                                            if (!((cf >= '0' && cf <= '9') || (cf >= 'A' && cf <= 'F') || (cf >= 'a' && cf <= 'f'))) {
                                                                break;
                                                            }
                                Severity: Major
                                Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 40 mins to fix

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

                                      static int parseIntFromReference(final String text, final int start, final int end, final int radix) {
                                          int result = 0;
                                          for (int i = start; i < end; i++) {
                                              final char c = text.charAt(i);
                                              int n = -1;
                                  Severity: Minor
                                  Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.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 parseIntFromReference has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      static int parseIntFromReference(final char[] text, final int start, final int end, final int radix) {
                                          int result = 0;
                                          for (int i = start; i < end; i++) {
                                              final char c = text[i];
                                              int n = -1;
                                  Severity: Minor
                                  Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.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

                                          return (c1 != '0' || c2 != '0' || c3 != '0'); // Check it's not U+0000 (escaped) + '00'
                                  Severity: Major
                                  Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return (c1 != '0' || c2 != '0'); // It would not be an octal escape, but the U+0000 escape sequence + '0'.
                                    Severity: Major
                                    Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return (c1 != '0' || c2 != '0'); // It would not be an octal escape, but the U+0000 escape sequence + '0'.
                                      Severity: Major
                                      Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                return (c1 != '0' || c2 != '0' || c3 != '0'); // Check it's not U+0000 (escaped) + '00'
                                        Severity: Major
                                        Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                      return (c1 != '0' || c2 != '0'); // It would not be an octal escape, but the U+0000 escape sequence + '0'.
                                          Severity: Major
                                          Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                        return (c1 != '0' || c2 != '0'); // It would not be an octal escape, but the U+0000 escape sequence + '0'.
                                            Severity: Major
                                            Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 30 mins to fix

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

                                                              switch (c1) {
                                                                  case '0': if (!isOctalEscape(text,i + 1,max)) { codepoint = 0x00; referenceOffset = i + 1; }; break;
                                                                  case 'b': codepoint = 0x08; referenceOffset = i + 1; break;
                                                                  case 't': codepoint = 0x09; referenceOffset = i + 1; break;
                                                                  case 'n': codepoint = 0x0A; referenceOffset = i + 1; break;
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 872..884

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

                                              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

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

                                                              switch (c1) {
                                                                  case '0': if (!isOctalEscape(text,i + 1,max)) { codepoint = 0x00; referenceOffset = i + 1; }; break;
                                                                  case 'b': codepoint = 0x08; referenceOffset = i + 1; break;
                                                                  case 't': codepoint = 0x09; referenceOffset = i + 1; break;
                                                                  case 'n': codepoint = 0x0A; referenceOffset = i + 1; break;
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 665..677

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

                                              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 (c1 == ESCAPE_XHEXA_PREFIX2) {
                                                                      // This can be a xhexa escape, we need exactly two more characters
                                              
                                                                      int f = i + 2;
                                                                      while (f < (i + 4) && f < max) {
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 914..940

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

                                              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

                                                                  } else if (c1 == ESCAPE_UHEXA_PREFIX2) {
                                                                      // This can be a uhexa escape, we need exactly four more characters
                                              
                                                                      int f = i + 2;
                                                                      while (f < (i + 6) && f < max) {
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 888..914

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

                                              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

                                                                  } else if (c1 == ESCAPE_UHEXA_PREFIX2) {
                                                                      // This can be a uhexa escape, we need exactly four more characters
                                              
                                                                      int f = i + 2;
                                                                      while (f < (i + 6) && f < max) {
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 681..707

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

                                              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 (c1 == ESCAPE_XHEXA_PREFIX2) {
                                                                      // This can be a xhexa escape, we need exactly two more characters
                                              
                                                                      int f = i + 2;
                                                                      while (f < (i + 4) && f < max) {
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 707..733

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

                                              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

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

                                                                  } else if (c1 == '8' || c1 == '9' || c1 == '\n' || c1 == '\r' || c1 == '\u2028' || c1 == '\u2029') {
                                              
                                                                      // '8' and '9' are not valid octal escape sequences, and the other four characters
                                                                      // are LineTerminators, which are not allowed as escape sequences. So we leave it as is
                                                                      // and expect the corresponding JavaScript engine to fail (except in the case of slash + '\n',
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 963..980

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

                                              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

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

                                                                  } else if (c1 == '8' || c1 == '9' || c1 == '\n' || c1 == '\r' || c1 == '\u2028' || c1 == '\u2029') {
                                              
                                                                      // '8' and '9' are not valid octal escape sequences, and the other four characters
                                                                      // are LineTerminators, which are not allowed as escape sequences. So we leave it as is
                                                                      // and expect the corresponding JavaScript engine to fail (except in the case of slash + '\n',
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 757..774

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

                                              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 (Character.charCount(codepoint) > 1) {
                                                              final char[] codepointChars = Character.toChars(codepoint);
                                                              writer.write(ESCAPE_UHEXA_PREFIX);
                                                              writer.write(toUHexa(codepointChars[0]));
                                                              writer.write(ESCAPE_UHEXA_PREFIX);
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 337..344

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

                                              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 (Character.charCount(codepoint) > 1) {
                                                              final char[] codepointChars = Character.toChars(codepoint);
                                                              strBuilder.append(ESCAPE_UHEXA_PREFIX);
                                                              strBuilder.append(toUHexa(codepointChars[0]));
                                                              strBuilder.append(ESCAPE_UHEXA_PREFIX);
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 483..490

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

                                              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

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

                                                          if (codepoint > (ESCAPE_LEVELS_LEN - 2) && level < ESCAPE_LEVELS[ESCAPE_LEVELS_LEN - 1] &&
                                                                  codepoint != '\u2028' && codepoint != '\u2029') {
                                              
                                                              if (Character.charCount(codepoint) > 1) {
                                                                  // This is to compensate that we are actually escaping two char[] positions with a single codepoint.
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 420..430

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

                                              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

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

                                                          if (codepoint > (ESCAPE_LEVELS_LEN - 2) && level < ESCAPE_LEVELS[ESCAPE_LEVELS_LEN - 1] &&
                                                                  codepoint != '\u2028' && codepoint != '\u2029') {
                                              
                                                              if (Character.charCount(codepoint) > 1) {
                                                                  // This is to compensate that we are actually escaping two char[] positions with a single codepoint.
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 269..279

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

                                              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

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

                                                                      if (codepoint > 0xFF) {
                                                                          // Maximum octal escape char is FF. Ignore the last digit
                                                                          codepoint = parseIntFromReference(text, i + 1, f - 1, 8);
                                                                          referenceOffset = f - 2;
                                                                      } else {
                                              Severity: Minor
                                              Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java and 1 other location - About 50 mins to fix
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 953..959

                                              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

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

                                                                      if (codepoint > 0xFF) {
                                                                          // Maximum octal escape char is FF. Ignore the last digit
                                                                          codepoint = parseIntFromReference(text, i + 1, f - 1, 8);
                                                                          referenceOffset = f - 2;
                                                                      } else {
                                              Severity: Minor
                                              Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java and 1 other location - About 50 mins to fix
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 747..753

                                              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

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

                                                          for (int j = 0; j < HEXA_CHARS_UPPER.length; j++) {
                                                              if (c == HEXA_CHARS_UPPER[j] || c == HEXA_CHARS_LOWER[j]) {
                                                                  n = j;
                                                                  break;
                                                              }
                                              Severity: Minor
                                              Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java and 1 other location - About 50 mins to fix
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 545..550

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

                                              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

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

                                                          for (int j = 0; j < HEXA_CHARS_UPPER.length; j++) {
                                                              if (c == HEXA_CHARS_UPPER[j] || c == HEXA_CHARS_LOWER[j]) {
                                                                  n = j;
                                                                  break;
                                                              }
                                              Severity: Minor
                                              Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java and 1 other location - About 50 mins to fix
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 529..534

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

                                              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 (useSECs && codepoint < SEC_CHARS_LEN) {
                                                              // We will try to use a SEC
                                              
                                                              final char sec = SEC_CHARS[codepoint];
                                              
                                              
                                              Severity: Minor
                                              Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java and 1 other location - About 45 mins to fix
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 458..470

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

                                              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 (useSECs && codepoint < SEC_CHARS_LEN) {
                                                              // We will try to use a SEC
                                              
                                                              final char sec = SEC_CHARS[codepoint];
                                              
                                              
                                              Severity: Minor
                                              Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java and 1 other location - About 45 mins to fix
                                              zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java on lines 312..324

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

                                              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