zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java

Summary

Maintainability
F
1 wk
Test Coverage

Method getMethod has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
Open

    @SuppressWarnings("null")
    public static Method getMethod(Object base, Object property,
            Class<?>[] paramTypes, Object[] paramValues)
            throws MethodNotFoundException {
        if (base == null || property == null) {
Severity: Minor
Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.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 ReflectionUtil.java has 402 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
Severity: Minor
Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java - About 5 hrs to fix

    Method getMethod has 112 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @SuppressWarnings("null")
        public static Method getMethod(Object base, Object property,
                Class<?>[] paramTypes, Object[] paramValues)
                throws MethodNotFoundException {
            if (base == null || property == null) {
    Severity: Major
    Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java - About 4 hrs to fix

      Method resolveAmbiguousMethod has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          private static Method resolveAmbiguousMethod(Set<Method> candidates,
                  Class<?>[] paramTypes) {
              // Identify which parameter isn't an exact match
              Method m = candidates.iterator().next();
      
      Severity: Minor
      Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method getMethod has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private static Method getMethod(Class<?> type, Method m) {
              if (m == null || Modifier.isPublic(type.getModifiers())) {
                  return m;
              }
              Class<?>[] inf = type.getInterfaces();
      Severity: Minor
      Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.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 resolveAmbiguousMethod has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static Method resolveAmbiguousMethod(Set<Method> candidates,
                  Class<?>[] paramTypes) {
              // Identify which parameter isn't an exact match
              Method m = candidates.iterator().next();
      
      Severity: Minor
      Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java - About 1 hr to fix

        Method populateSetters has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            private static Method[] populateSetters(Class<?> cls, String propertyName) {
                String setterName = "";
                if (propertyName != null && propertyName.length() > 0){
                    setterName = new StringBuilder("set").append(propertyName.substring(0, 1).toUpperCase(Locale.ENGLISH))
                            .append(propertyName.substring(1)).toString();
        Severity: Minor
        Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.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 isAssignableFrom has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            private static boolean isAssignableFrom(Class<?> src, Class<?> target) {
                // src will always be an object
                // Short-cut. null is always assignable to an object and in EL null
                // can always be coerced to a valid value for a primitive
                if (src == null) {
        Severity: Minor
        Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.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 getMethod has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static Method getMethod(Class<?> type, Method m) {
                if (m == null || Modifier.isPublic(type.getModifiers())) {
                    return m;
                }
                Class<?>[] inf = type.getInterfaces();
        Severity: Minor
        Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java - About 1 hr to fix

          Method isAssignableFrom has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static boolean isAssignableFrom(Class<?> src, Class<?> target) {
                  // src will always be an object
                  // Short-cut. null is always assignable to an object and in EL null
                  // can always be coerced to a valid value for a primitive
                  if (src == null) {
          Severity: Minor
          Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java - About 1 hr to fix

            Method paramString has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private static final String paramString(Class<?>[] types) {
                    if (types != null) {
                        StringBuilder sb = new StringBuilder();
                        for (int i = 0; i < types.length; i++) {
                            if (types[i] == null) {
            Severity: Minor
            Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java - About 55 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 forName has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public static Class<?> forName(String name) throws ClassNotFoundException {
                    if (null == name || "".equals(name)) {
                        return null;
                    }
                    Class<?> c = forNamePrimitive(name);
            Severity: Minor
            Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                    public int compareTo(MatchResult o) {
                        int cmp = compare(this.getExact(), o.getExact());
                        if (cmp == 0) {
                            cmp = compare(this.getAssignable(), o.getAssignable());
                            if (cmp == 0) {
            Severity: Minor
            Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                private static Method resolveAmbiguousMethod(Set<Method> candidates,
                        Class<?>[] paramTypes) {
                    // Identify which parameter isn't an exact match
                    Method m = candidates.iterator().next();
            
            zel/src/main/java/org/zkoss/zel/Util.java on lines 388..449

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

            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 class MatchResult implements Comparable<MatchResult> {
            
                    private final int exact;
                    private final int assignable;
                    private final int coercible;
            zel/src/main/java/org/zkoss/zel/Util.java on lines 734..787

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

            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 i = 0; i < mParamCount; i++) {
                            // Can't be null
                            if (mParamTypes[i].equals(paramTypes[i])) {
                                exactMatch++;
                            } else if (i == (mParamCount - 1) && m.isVarArgs()) {
            zel/src/main/java/org/zkoss/zel/Util.java on lines 265..306

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

            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 Method getMethod(Class<?> type, Method m) {
                    if (m == null || Modifier.isPublic(type.getModifiers())) {
                        return m;
                    }
                    Class<?>[] inf = type.getInterfaces();
            zel/src/main/java/org/zkoss/zel/Util.java on lines 527..557

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

            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 boolean isAssignableFrom(Class<?> src, Class<?> target) {
                    // src will always be an object
                    // Short-cut. null is always assignable to an object and in EL null
                    // can always be coerced to a valid value for a primitive
                    if (src == null) {
            zel/src/main/java/org/zkoss/zel/Util.java on lines 456..487

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

            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 String paramString(Class<?>[] types) {
                    if (types != null) {
                        StringBuilder sb = new StringBuilder();
                        for (int i = 0; i < types.length; i++) {
                            if (types[i] == null) {
            zel/src/main/java/org/zkoss/zel/Util.java on lines 365..381

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

            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 (Map.Entry<Method, MatchResult> entry : candidates.entrySet()) {
                        int cmp = entry.getValue().compareTo(bestMatch);
                        if (cmp > 0 || match == null) {
                            bestMatch = entry.getValue();
                            match = entry.getKey();
            zel/src/main/java/org/zkoss/zel/Util.java on lines 326..335

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

            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

                public static Class<?>[] toTypeArray(String[] s) throws ClassNotFoundException {
                    if (s == null)
                        return null;
                    Class<?>[] c = new Class[s.length];
                    for (int i = 0; i < s.length; i++) {
            zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java on lines 121..129

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

            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

                public static String[] toTypeNameArray(Class<?>[] c) {
                    if (c == null)
                        return null;
                    String[] s = new String[c.length];
                    for (int i = 0; i < c.length; i++) {
            zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java on lines 105..113

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

            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 (bestMatch.getExact() == paramCount - 1) {
                            // Only one parameter is not an exact match - try using the
                            // super class
                            match = resolveAmbiguousMethod(candidates.keySet(), paramTypes);
                        } else {
            Severity: Minor
            Found in zel/src/main/java/org/zkoss/zel/impl/util/ReflectionUtil.java and 1 other location - About 30 mins to fix
            zel/src/main/java/org/zkoss/zel/Util.java on lines 337..343

            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