zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.java

Summary

Maintainability
F
3 days
Test Coverage

ComponentsCtrl has 54 methods (exceeds 20 allowed). Consider refactoring.
Open

public class ComponentsCtrl {
    private static final ThreadLocal<Object> _compdef = new ThreadLocal<>();
    private static final ThreadLocal<Component> _rootParent = new ThreadLocal<>();

    /** Returns the automatically generate component's UUID/ID.
Severity: Major
Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.java - About 7 hrs to fix

    Method parseEventExpression has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        public static Object[] parseEventExpression(Component comp, String evtexpr, Component defaultComp, boolean deferred)
                throws ComponentNotFoundException {
            final int j = evtexpr.lastIndexOf('.');
            final String evtnm;
            Object target;
    Severity: Minor
    Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.java - About 6 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

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

    /* ComponentsCtrl.java
    
        Purpose:
            
        Description:
    Severity: Minor
    Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.java - About 4 hrs to fix

      Method applyForward0 has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          private static final void applyForward0(Component comp, String orgEvent, String cond) {
              int len;
              if (cond == null || (len = cond.length()) == 0)
                  len = (cond = orgEvent).length();
              //if condition not specified, assume same as orgEvent (to space owenr)
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.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 parseEventExpression has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static Object[] parseEventExpression(Component comp, String evtexpr, Component defaultComp, boolean deferred)
                  throws ComponentNotFoundException {
              final int j = evtexpr.lastIndexOf('.');
              final String evtnm;
              Object target;
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.java - About 1 hr to fix

        Method applyForward0 has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static final void applyForward0(Component comp, String orgEvent, String cond) {
                int len;
                if (cond == null || (len = cond.length()) == 0)
                    len = (cond = orgEvent).length();
                //if condition not specified, assume same as orgEvent (to space owenr)
        Severity: Minor
        Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.java - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      if ((cc < 'a' || cc > 'z') && (cc < 'A' || cc > 'Z') && (cc < '0' || cc > '9') && cc != '_')
                          throw new UiException("Illegal character, " + cc + ", not allowed in uuid, " + uuid);
          Severity: Major
          Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.java - About 1 hr to fix

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

                public static void checkUuid(String uuid) {
                    int j;
                    if (uuid == null || (j = uuid.length()) == 0)
                        throw new UiException("uuid cannot be null or empty");
            
            
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.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 encodeId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public static final String encodeId(StringBuffer sb, int val) {
                    //Thus, the number will 0, 1... max, 0, 1..., max, 0, 1 (less conflict)
                    if (val < 0 && (val += Integer.MIN_VALUE) < 0)
                        val = -val; //impossible but just in case
            
            
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.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 applyForward has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public static final void applyForward(Component comp, String forward) {
                    if (forward == null)
                        return;
            
                    final Map<String, Collection<String>> fwds = new LinkedHashMap<String, Collection<String>>(); //remain the order
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.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 getEventMethod has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public static final Method getEventMethod(Class<?> cls, String evtnm) {
                    final Pair<Class<?>, String> key = new Pair<Class<?>, String>(cls, evtnm);
                    final Object o = _evtmtds.get(key);
                    if (o != null)
                        return o == Objects.UNKNOWN ? null : (Method) o;
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/ui/sys/ComponentsCtrl.java - About 25 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

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

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status