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

Summary

Maintainability
F
1 wk
Test Coverage

Method load has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring.
Open

    public final static void load(Map<? super String, ? super String> map, InputStream sm, String charset,
    boolean caseInsensitive) throws IOException {
        final PushbackInputStream pis = new PushbackInputStream(sm, 3);
        if (charset == null || charset.startsWith("UTF")) {
            final byte[] ahead = new byte[3];
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/Maps.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 parse0 has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

    private static final Map
    parse0(Map map, String src, char pairSeparator, char separator, char quote, boolean asValue,
    boolean parenthesis, boolean multiple)
    throws IllegalSyntaxException {
        if (separator == (char)0)
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/Maps.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 Maps.java has 468 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* Maps.java


    Purpose: Utilities for Map
    Description: 
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 7 hrs to fix

    Method load has 100 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public final static void load(Map<? super String, ? super String> map, InputStream sm, String charset,
        boolean caseInsensitive) throws IOException {
            final PushbackInputStream pis = new PushbackInputStream(sm, 3);
            if (charset == null || charset.startsWith("UTF")) {
                final byte[] ahead = new byte[3];
    Severity: Major
    Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 4 hrs to fix

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

          private static final Map
          parse0(Map map, String src, char pairSeparator, char separator, char quote, boolean asValue,
          boolean parenthesis, boolean multiple)
          throws IllegalSyntaxException {
              if (separator == (char)0)
      Severity: Major
      Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 3 hrs to fix

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

            private static final Token
            next(String src, String delimiters, int j, boolean whitespaceAware,
            boolean parenthesis) {
                final StringBuffer tksb = new StringBuffer(64);
                final int len = src.length();
        Severity: Minor
        Found in zcommon/src/main/java/org/zkoss/util/Maps.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

        Maps has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

        public class Maps {
            private static final Logger log = LoggerFactory.getLogger(Maps.class);
        
            /**
             * Reads a property list (key and element pairs) from the input stream,
        Severity: Minor
        Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 2 hrs to fix

          Method toStringBuffer has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              public static final StringBuffer
              toStringBuffer(StringBuffer sb, Map<? super String, ? super String> map, char quote, char separator, char pairSeparator) {
                  if (separator == (char)0)
                      throw new IllegalArgumentException("Separator cannot be 0");
                  if (map.isEmpty())
          Severity: Minor
          Found in zcommon/src/main/java/org/zkoss/util/Maps.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 next has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static final Token
              next(String src, String delimiters, int j, boolean whitespaceAware,
              boolean parenthesis) {
                  final StringBuffer tksb = new StringBuffer(64);
                  final int len = src.length();
          Severity: Minor
          Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 1 hr to fix

            Method toStringBuffer has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static final StringBuffer
                toStringBuffer(StringBuffer sb, Map<? super String, ? super String> map, char quote, char separator, char pairSeparator) {
                    if (separator == (char)0)
                        throw new IllegalArgumentException("Separator cannot be 0");
                    if (map.isEmpty())
            Severity: Minor
            Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 1 hr to fix

              Method parse0 has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  parse0(Map map, String src, char pairSeparator, char separator, char quote, boolean asValue,
                  boolean parenthesis, boolean multiple)
              Severity: Major
              Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 1 hr to fix

                Method parseMultiple has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    parseMultiple(Map<? super String, Collection<String>> map,
                    String src, char pairSeparator, char separator, char quote, boolean asValue,
                    boolean parenthesis) throws IllegalSyntaxException {
                Severity: Major
                Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 50 mins to fix

                  Method parse has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      parse(Map<? super String, ? super String> map,
                      String src,char pairSeparator, char separator, char quote, boolean asValue,
                      boolean parenthesis) throws IllegalSyntaxException {
                  Severity: Major
                  Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 50 mins to fix

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

                        parse(Map<? super String, ? super String> map,
                        String src, char separator, char quote, boolean asValue,
                        boolean parenthesis) throws IllegalSyntaxException {
                    Severity: Minor
                    Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 45 mins to fix

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

                          parseMultiple(Map<? super String, Collection<String>> map,
                          String src, char separator, char quote, boolean asValue,
                          boolean parenthesis) throws IllegalSyntaxException {
                      Severity: Minor
                      Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if (j >= 0 && line.charAt(j) == '}') {
                                                        if (j > 0)
                                                            j = 1 + Strings.skipWhitespacesBackward(line, j - 1);
                                                        if (j == 0) //no non-space before }
                                                            break;
                        Severity: Major
                        Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 45 mins to fix

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

                              toStringBuffer(StringBuffer sb, Map<? super String, ? super String> map, char quote, char separator, char pairSeparator) {
                          Severity: Minor
                          Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 35 mins to fix

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

                                parse(Map<? super String, ? super String> map, String src, char separator, char quote, boolean asValue)
                            Severity: Minor
                            Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 35 mins to fix

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

                                  parse(Map<? super String, ? super String> map, String src, char pairSeparator, char separator, char quote)
                              Severity: Minor
                              Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 35 mins to fix

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

                                    next(String src, String delimiters, int j, boolean whitespaceAware,
                                    boolean parenthesis) {
                                Severity: Minor
                                Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 35 mins to fix

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

                                      @SuppressWarnings("unchecked")
                                      private static void put(Map map, String name, String value, boolean multiple) {
                                          if (multiple) {
                                              List l = (List)map.get(name);
                                              if (l == null)
                                  Severity: Minor
                                  Found in zcommon/src/main/java/org/zkoss/util/Maps.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 skipParenthesis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private static int skipParenthesis(String src, int j, char beg, char end) {
                                          for (int len = src.length(), depth = 0; ++j < len;) {
                                              final char cc = src.charAt(j);
                                              if (cc == '\\') ++j; //skip next
                                              else if (cc == beg) ++depth;
                                  Severity: Minor
                                  Found in zcommon/src/main/java/org/zkoss/util/Maps.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 getEndingParenthesis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private static final char getEndingParenthesis(char cc) {
                                          return cc == '{' ? '}': cc == '(' ? ')': cc == '[' ? ']': (char)0;
                                      }
                                  Severity: Minor
                                  Found in zcommon/src/main/java/org/zkoss/util/Maps.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

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

                                      private static int skipParenthesis(String src, int j, char beg, char end) {
                                          for (int len = src.length(), depth = 0; ++j < len;) {
                                              final char cc = src.charAt(j);
                                              if (cc == '\\') ++j; //skip next
                                              else if (cc == beg) ++depth;
                                  Severity: Major
                                  Found in zcommon/src/main/java/org/zkoss/util/Maps.java and 1 other location - About 1 hr to fix
                                  zcommon/src/main/java/org/zkoss/lang/Strings.java on lines 783..792

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

                                  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

                                      private static final char getEndingParenthesis(char cc) {
                                          return cc == '{' ? '}': cc == '(' ? ')': cc == '[' ? ']': (char)0;
                                      }
                                  Severity: Minor
                                  Found in zcommon/src/main/java/org/zkoss/util/Maps.java and 1 other location - About 30 mins to fix
                                  zcommon/src/main/java/org/zkoss/lang/Strings.java on lines 776..778

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

                                  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