zul/src/main/java/org/zkoss/zul/Treechildren.java

Summary

Maintainability
D
1 day
Test Coverage

Treechildren has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

public class Treechildren extends XulElement {
    private static final String VISIBLE_ITEM = "org.zkoss.zul.Treechildren.visibleItem";

    private int _visibleItemCount;

Severity: Minor
Found in zul/src/main/java/org/zkoss/zul/Treechildren.java - About 3 hrs to fix

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

        public Collection<Treeitem> getItems() {
            return new AbstractCollection<Treeitem>() {
                public int size() {
                    return getItemCount();
                }
    Severity: Minor
    Found in zul/src/main/java/org/zkoss/zul/Treechildren.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 getAvailableAtClient has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

            public Set<? extends Component> getAvailableAtClient() {
                if (!isCropper())
                    return null;
    
                final Tree tree = getTree();
    Severity: Minor
    Found in zul/src/main/java/org/zkoss/zul/Treechildren.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 getItems has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public Collection<Treeitem> getItems() {
            return new AbstractCollection<Treeitem>() {
                public int size() {
                    return getItemCount();
                }
    Severity: Minor
    Found in zul/src/main/java/org/zkoss/zul/Treechildren.java - About 1 hr to fix

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

          @SuppressWarnings("unchecked")
          protected void smartUpdate(String name, Object value) {
              Component comp = getParent();
              if (comp instanceof Treeitem) {
                  Treerow tr = ((Treeitem) comp).getTreerow();
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Treechildren.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 addVisibleItemCount has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          /*package*/ void addVisibleItemCount(int count) {
              if (count == 0)
                  return;
              Component parent = getParent();
              if (parent instanceof Treeitem) {
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Treechildren.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 setParent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public void setParent(Component parent) {
              final Component oldp = getParent();
              if (oldp == parent)
                  return; //nothing changed
      
      
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Treechildren.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 hasNext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              public boolean hasNext() {
                  if (_tree == null || !_tree.inPagingMold())
                      return _it.hasNext();
      
                  Integer renderedCount = (Integer) _tree.getAttribute(Attributes.RENDERED_ITEM_COUNT);
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Treechildren.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

          public void setParent(Component parent) {
              final Component oldp = getParent();
              if (oldp == parent)
                  return; //nothing changed
      
      
      Severity: Major
      Found in zul/src/main/java/org/zkoss/zul/Treechildren.java and 1 other location - About 1 hr to fix
      zul/src/main/java/org/zkoss/zul/Treeitem.java on lines 471..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 98.

      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 3 locations. Consider refactoring.
      Open

          public void beforeParentChanged(Component parent) {
              if (parent != null && !(parent instanceof Tree) && !(parent instanceof Treeitem))
                  throw new UiException("Wrong parent: " + parent);
              super.beforeParentChanged(parent);
          }
      Severity: Major
      Found in zul/src/main/java/org/zkoss/zul/Treechildren.java and 2 other locations - About 40 mins to fix
      zul/src/main/java/org/zkoss/zul/Menu.java on lines 151..155
      zul/src/main/java/org/zkoss/zul/Menuitem.java on lines 271..275

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

      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 4 locations. Consider refactoring.
      Open

          public Tree getTree() {
              for (Component p = this; (p = p.getParent()) != null;)
                  if (p instanceof Tree)
                      return (Tree) p;
              return null;
      Severity: Major
      Found in zul/src/main/java/org/zkoss/zul/Treechildren.java and 3 other locations - About 30 mins to fix
      zul/src/main/java/org/zkoss/zul/Treecell.java on lines 52..57
      zul/src/main/java/org/zkoss/zul/Treeitem.java on lines 395..400
      zul/src/main/java/org/zkoss/zul/Treerow.java on lines 41..46

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

      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