zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java

Summary

Maintainability
F
4 days
Test Coverage

File Selectors.java has 527 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * 
 */
package org.zkoss.zk.ui.select;
Severity: Major
Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 1 day to fix

    Method splitListenAnnotationValues has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        private static String[][] splitListenAnnotationValues(String str) {
            List<String[]> result = new ArrayList<String[]>();
            int len = str.length();
            boolean inSqBracket = false;
            boolean inQuote = false;
    Severity: Minor
    Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.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 injectComponent has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

            @SuppressWarnings("unchecked")
            private void injectComponent(InjectionFunctor injector, Iterable<Component> comps) {
                Class<?> type = injector.getType();
                boolean isField = injector instanceof FieldFunctor;
                // Array
    Severity: Minor
    Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.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

    Selectors has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class Selectors {
    
        /**
         * Returns an Iterable that iterates through all Components matched by the
         * selector. 
    Severity: Minor
    Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 3 hrs to fix

      Method splitListenAnnotationValues has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static String[][] splitListenAnnotationValues(String str) {
              List<String[]> result = new ArrayList<String[]>();
              int len = str.length();
              boolean inSqBracket = false;
              boolean inQuote = false;
      Severity: Major
      Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 2 hrs to fix

        Method wireEventListeners0 has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static void wireEventListeners0(final Component component, final Object controller, final boolean rewire) {
                Reflections.forMethods(controller.getClass(), Listen.class, new MethodRunner<Listen>() {
                    public void onMethod(Class<?> clazz, Method method, Listen anno) {
                        // check method signature
                        if ((method.getModifiers() & Modifier.STATIC) != 0)
        Severity: Minor
        Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 1 hr to fix

          Method wireComponents has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  private void wireComponents(final PsdoCompFunctor functor, final boolean ignoreNonNull) {
                      final Class<?> ctrlClass = _controller.getClass();
                      // wire to fields
                      Reflections.forFields(ctrlClass, Wire.class, new FieldRunner<Wire>() {
                          public void onField(Class<?> clazz, Field field, Wire anno) {
          Severity: Minor
          Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 1 hr to fix

            Method injectComponent has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    @SuppressWarnings("unchecked")
                    private void injectComponent(InjectionFunctor injector, Iterable<Component> comps) {
                        Class<?> type = injector.getType();
                        boolean isField = injector instanceof FieldFunctor;
                        // Array
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 1 hr to fix

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

                      private void wireVariables(final PsdoCompFunctor functor, final List<VariableResolver> resolvers) {
                          Class<?> ctrlClass = _controller.getClass();
                          // wire to fields
                          Reflections.forFields(ctrlClass, WireVariable.class, new FieldRunner<WireVariable>() {
                              public void onField(Class<?> clazz, Field field, WireVariable anno) {
              Severity: Minor
              Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 1 hr to fix

                Method newVariableResolvers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static List<VariableResolver> newVariableResolvers(Class<?> cls, Class<?> untilClass) {
                        final List<VariableResolver> resolvers = new ArrayList<VariableResolver>();
                        while (cls != null && cls != untilClass) {
                            final org.zkoss.zk.ui.select.annotation.VariableResolver anno = cls
                                    .getAnnotation(org.zkoss.zk.ui.select.annotation.VariableResolver.class);
                Severity: Minor
                Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.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 getObjectByName has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                        private Object getObjectByName(PsdoCompFunctor functor, String name, Class<?> type,
                                List<VariableResolver> resolvers) {
                
                            Object result = functor.getXelVariable(name);
                            if (isValidValue(result, type))
                Severity: Minor
                Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.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

                Avoid deeply nested control flow statements.
                Open

                                                for (EventListener<? extends Event> listener : listeners)
                                                    if (listener instanceof ComposerEventListener)
                                                        c.removeEventListener(name, listener);
                Severity: Major
                Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 45 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return "log";
                  Severity: Major
                  Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return null;
                    Severity: Major
                    Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return "application";
                      Severity: Major
                      Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return null;
                        Severity: Major
                        Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.java - About 30 mins to fix

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

                              private static String guessImplicitObjectName(Class<?> cls) {
                                  if (Execution.class.equals(cls))
                                      return "execution";
                                  if (Page.class.equals(cls))
                                      return "page";
                          Severity: Minor
                          Found in zk/src/main/java/org/zkoss/zk/ui/select/Selectors.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

                          There are no issues that match your filters.

                          Category
                          Status