zk/src/main/java/org/zkoss/zk/ui/Templates.java

Summary

Maintainability
D
2 days
Test Coverage

Method lookup has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring.
Open

    public static Template lookup(Component comp, Component base, String name, Component compBase,
            boolean excludeBase) {
        if (comp == null)
            return null;
        Template template = (excludeBase && comp == base) ? null : comp.getTemplate(name);
Severity: Minor
Found in zk/src/main/java/org/zkoss/zk/ui/Templates.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 findShadowChildTemplate has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private static Template findShadowChildTemplate(HtmlShadowElement shadow, Component compBase, String name) {
        List<ShadowElement> children = cast(shadow.getChildren());
        if (!children.isEmpty()) {
            Template t;
            for (ShadowElement child : children) {
Severity: Minor
Found in zk/src/main/java/org/zkoss/zk/ui/Templates.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 lookup has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static Template lookup(Component comp, Component base, String name, Component compBase,
            boolean excludeBase) {
        if (comp == null)
            return null;
        Template template = (excludeBase && comp == base) ? null : comp.getTemplate(name);
Severity: Major
Found in zk/src/main/java/org/zkoss/zk/ui/Templates.java - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                                    if (tmp != null) {
                                        if (template == null) {
                                            // Bug ZK-2855: only assign first match, all following matches will be discarded
                                            template = tmp;
                                        }
    Severity: Major
    Found in zk/src/main/java/org/zkoss/zk/ui/Templates.java - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (t != null)
                                  return t;
      Severity: Major
      Found in zk/src/main/java/org/zkoss/zk/ui/Templates.java - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if (t != null)
                                    return t;
        Severity: Major
        Found in zk/src/main/java/org/zkoss/zk/ui/Templates.java - About 45 mins to fix

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

              public static Template lookup(Component comp, Component base, String name, Component compBase,
                      boolean excludeBase) {
          Severity: Minor
          Found in zk/src/main/java/org/zkoss/zk/ui/Templates.java - About 35 mins to fix

            Avoid too many return statements within this method.
            Open

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

              There are no issues that match your filters.

              Category
              Status