zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.java

Summary

Maintainability
F
3 days
Test Coverage

Method wireOthers has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    private void wireOthers(Object x) {
        //check methods
        final Class cls = _controller.getClass();
        Method[] mtds = cls.getMethods();
        for (int j = 0; j < mtds.length; ++j) {
Severity: Minor
Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.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 ConventionWire.java has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* ConventionWire.java

    Purpose:
        
    Description:
Severity: Minor
Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.java - About 3 hrs to fix

    Method getVariable has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        private Object getVariable(Object x, String fdname) {
            //#feature 2770471 GenericAutowireComposer shall support wiring ZScript varible
            if (x instanceof Page) {
                final Page page = (Page) x;
                Object arg = _ignoreZScript ? null : page.getZScriptVariable(fdname);
    Severity: Minor
    Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.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 injectByMethod has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        private boolean injectByMethod(Method md, Class<?> parmcls, Class<?> argcls, Object arg, String fdname) {
            if (argcls == null || parmcls.isAssignableFrom(argcls)) {
                final Field fd = _fldMaps.get(fdname);
                if (fd != null && fd.getType().equals(parmcls)) {
                    final boolean old = fd.isAccessible();
    Severity: Minor
    Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.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

    Consider simplifying this complex logical expression.
    Open

            if (x instanceof Page) {
                final Page page = (Page) x;
                return (!_ignoreZScript && page.getZScriptVariable(fdname) != null)
                        || page.hasAttributeOrFellow(fdname, true)
                        || (!_ignoreXel && page.getXelVariable(null, null, fdname, true) != null);
    Severity: Critical
    Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.java - About 2 hrs to fix

      Method injectByName has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          private void injectByName(Object arg, String fdname, boolean fieldOnly) {
              //argument to be injected is null; then no need to inject
              if (arg != null) {
                  final String mdname = Classes.toMethodName(fdname, "set");
                  final Class parmcls = arg.getClass();
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.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 wireFellows has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public void wireFellows(final IdSpace idspace) {
              //inject fellows
              final Collection<Component> fellows = idspace.getFellows();
              for (Component xcomp : fellows)
                  injectFellow(xcomp);
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.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 wireOthers has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void wireOthers(Object x) {
              //check methods
              final Class cls = _controller.getClass();
              Method[] mtds = cls.getMethods();
              for (int j = 0; j < mtds.length; ++j) {
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.java - About 1 hr to fix

        Method injectByMethod has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private boolean injectByMethod(Method md, Class<?> parmcls, Class<?> argcls, Object arg, String fdname) {
                if (argcls == null || parmcls.isAssignableFrom(argcls)) {
                    final Field fd = _fldMaps.get(fdname);
                    if (fd != null && fd.getType().equals(parmcls)) {
                        final boolean old = fd.isAccessible();
        Severity: Minor
        Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.java - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (arg2 != arg && arg2 != null)
                                      injectField(arg2, arg2.getClass(), fd);
          Severity: Major
          Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.java - About 45 mins to fix

            Method containsVariable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                private boolean containsVariable(Object x, String fdname) {
                    //#feature 2770471 GenericAutowireComposer shall support wiring ZScript varible
                    if (x instanceof Page) {
                        final Page page = (Page) x;
                        return (!_ignoreZScript && page.getZScriptVariable(fdname) != null)
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.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

                                    if (containsVariable(x, fdname)) {
                                        final Object arg = getVariable(x, fdname);
                                        if (!injectByMethod(md, parmcls[0], arg == null ? null : arg.getClass(), arg, fdname)) {
                                            final Object arg2 = getFellow(x, fdname);
                                            if (arg2 != arg && arg2 != null)
            Severity: Major
            Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.java - About 45 mins to fix

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

                  private boolean injectByMethod(Method md, Class<?> parmcls, Class<?> argcls, Object arg, String fdname) {
              Severity: Minor
              Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.java - About 35 mins to fix

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

                    @SuppressWarnings("unchecked")
                    public void wireImplicit(Object x) {
                        //Feature #3315689 
                        if (ignoreFromWire(_controller.getClass()))
                            return;
                Severity: Minor
                Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.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

                There are no issues that match your filters.

                Category
                Status