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

Summary

Maintainability
F
4 days
Test Coverage

Treeitem has 56 methods (exceeds 20 allowed). Consider refactoring.
Open

public class Treeitem extends XulElement implements org.zkoss.zk.ui.ext.Disable {
    private transient Treerow _treerow;
    private transient Treechildren _treechildren;
    private Object _value;
    private boolean _open = true;
Severity: Major
Found in zul/src/main/java/org/zkoss/zul/Treeitem.java - About 1 day to fix

    File Treeitem.java has 460 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* Treeitem.java
    
        Purpose:
    
        Description:
    Severity: Minor
    Found in zul/src/main/java/org/zkoss/zul/Treeitem.java - About 7 hrs to fix

      Method service has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

          public void service(org.zkoss.zk.au.AuRequest request, boolean everError) {
              final String cmd = request.getCommand();
              if (cmd.equals(Events.ON_OPEN)) {
                  OpenEvent evt = OpenEvent.getOpenEvent(request);
      
      
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Treeitem.java - About 5 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 redrawChildren has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          protected void redrawChildren(Writer out) throws IOException {
              Tree tree = getTree();
              if (!tree.inPagingMold()) {
                  super.redrawChildren(out);
              } else if (isRealVisible() && shallVisitTree(tree, this)) {
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Treeitem.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 service has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public void service(org.zkoss.zk.au.AuRequest request, boolean everError) {
              final String cmd = request.getCommand();
              if (cmd.equals(Events.ON_OPEN)) {
                  OpenEvent evt = OpenEvent.getOpenEvent(request);
      
      
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Treeitem.java - About 1 hr to fix

        Method setOpen has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public void setOpen(boolean open) {
                if (_open != open) {
                    _open = open;
                    //Note: _treerow might not be ready yet because it might be
                    //initialized before creating child components (for ZK pages)
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.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 afterUnmarshal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private void afterUnmarshal(int cnt) {
                for (Iterator it = getChildren().iterator(); it.hasNext();) {
                    final Object child = it.next();
                    if (child instanceof Treerow) {
                        _treerow = (Treerow) child;
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.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 insertBefore has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public boolean insertBefore(Component child, Component refChild) {
                if (child instanceof Treerow) {
                    if (super.insertBefore(child, refChild)) {
                        _treerow = (Treerow) child;
                        return true;
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.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 beforeChildAdded has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public void beforeChildAdded(Component child, Component refChild) {
                if (child instanceof Treerow) {
                    if (_treerow != null && _treerow != child)
                        throw new UiException("Only one treerow is allowed: " + this);
                } else if (child instanceof Treechildren) {
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.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 setVisible has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public boolean setVisible(boolean visible) {
                if (isVisible() != visible) {
                    smartUpdate("visible", visible);
                    int count = isOpen() && _treechildren != null ? _treechildren.getVisibleItemCount() + 1 : 1;
                    if (visible) {
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.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 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/Treeitem.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 shallVisitTree has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private static boolean shallVisitTree(Tree tree, Component child) {
                final Treeitem item = (Treeitem) child;
                int count = item.isOpen() && item.getTreechildren() != null ? item.getTreechildren().getVisibleItemCount() : 0;
                Integer visited = (Integer) tree.getAttribute(Attributes.VISITED_ITEM_COUNT);
                final Paginal pgi = tree.getPaginal();
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.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 getLevel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public int getLevel() {
                int level = 0;
                for (Component item = this;; ++level) {
                    final Component tch = item.getParent();
                    if (tch == null)
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.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/Treeitem.java and 1 other location - About 1 hr to fix
        zul/src/main/java/org/zkoss/zul/Treechildren.java on lines 206..223

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

                if (child instanceof Treerow) {
                    if (_treerow != null && _treerow != child)
                        throw new UiException("Only one treerow is allowed: " + this);
                } else if (child instanceof Treechildren) {
                    if (_treechildren != null && _treechildren != child)
        Severity: Major
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.java and 1 other location - About 1 hr to fix
        zul/src/main/java/org/zkoss/zul/Tabbox.java on lines 626..634

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

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

                if (child instanceof Treerow) {
                    if (super.insertBefore(child, refChild)) {
                        _treerow = (Treerow) child;
                        return true;
                    }
        Severity: Major
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.java and 1 other location - About 1 hr to fix
        zul/src/main/java/org/zkoss/zul/Tabbox.java on lines 653..666

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

        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

                    if (child instanceof Treerow) {
                        _treerow = (Treerow) child;
                        if (--cnt == 0)
                            break;
                    } else if (child instanceof Treechildren) {
        Severity: Major
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.java and 2 other locations - About 50 mins to fix
        zul/src/main/java/org/zkoss/zul/Grid.java on lines 1623..1631
        zul/src/main/java/org/zkoss/zul/Tabbox.java on lines 741..749

        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

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

                _properties.put("_loaded", new BooleanPropertyAccess() {
                    public void setValue(Component cmp, Boolean rendered) {
                        ((Treeitem) cmp).setRendered(rendered != null && rendered);
                    }
        
        
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.java and 1 other location - About 40 mins to fix
        zul/src/main/java/org/zkoss/zul/Treeitem.java on lines 659..667

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

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

                _properties.put("_loadedChildren", new BooleanPropertyAccess() {
                    public void setValue(Component cmp, Boolean loadedChildren) {
                        ((Treeitem) cmp).setLoaded(loadedChildren != null && loadedChildren);
                    }
        
        
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.java and 1 other location - About 40 mins to fix
        zul/src/main/java/org/zkoss/zul/Treeitem.java on lines 668..676

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

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

            public void setSelectable(boolean selectable) {
                if (_selectable != selectable) {
                    _selectable = selectable;
        
                    // non-checkable cannot be selected
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Treeitem.java and 1 other location - About 30 mins to fix
        zul/src/main/java/org/zkoss/zul/Listitem.java on lines 100..109

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

        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/Treeitem.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/Treechildren.java on lines 52..57
        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