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

Summary

Maintainability
D
2 days
Test Coverage

ListModelSet has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

public class ListModelSet<E> extends AbstractListModel<E> implements Sortable<E>, Set<E>, java.io.Serializable {
    private static final long serialVersionUID = 20120206122849L;

    protected Set<E> _set;

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

    File ListModelSet.java has 285 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* ListModelSet.java
    
    {{IS_NOTE
        Purpose:
            
    Severity: Minor
    Found in zul/src/main/java/org/zkoss/zul/ListModelSet.java - About 2 hrs to fix

      Method removePartial has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          private boolean removePartial(Collection<?> c, boolean isRemove) {
              int sz = c.size();
              int removed = 0;
              int retained = 0;
              int index = 0;
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/ListModelSet.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 removePartial has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private boolean removePartial(Collection<?> c, boolean isRemove) {
              int sz = c.size();
              int removed = 0;
              int retained = 0;
              int index = 0;
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/ListModelSet.java - About 1 hr to fix

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

            public boolean addAll(Collection<? extends E> c) {
                if (_set instanceof LinkedHashSet) {
                    int begin = _set.size();
                    int added = 0;
                    for (final Iterator<? extends E> it = c.iterator(); it.hasNext();) {
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.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 iterator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public Iterator<E> iterator() {
                return new Iterator<E>() {
                    private Iterator<E> _it = _set.iterator();
                    private E _current = null;
                    private int _nextIndex;
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.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 removeAll has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public boolean removeAll(Collection<?> c) {
                if (_set == c || this == c) { //special case
                    clear();
                    return true;
                }
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.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

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

            public boolean retainAll(Collection<?> c) {
                if (_set == c || this == c) { //special case
                    return false;
                }
                //bug #1819318 Problem while using SortedSet with Databinding
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.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

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

            public boolean remove(Object o) {
                boolean ret = false;
                if (_set.contains(o)) {
                    //bug #1819318 Problem while using SortedSet with Databinding
                    removeFromSelection(o);
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.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 add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public boolean add(E o) {
                if (!_set.contains(o)) {
                    boolean ret = _set.add(o);
                    //After add, the position can change if not LinkedHashSet
                    //bug #1819318 Problem while using SortedSet with Databinding
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.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

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

            public boolean remove(Object o) {
                boolean ret = false;
                if (_set.contains(o)) {
                    //bug #1819318 Problem while using SortedSet with Databinding
                    removeFromSelection(o);
        Severity: Major
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.java and 1 other location - About 1 hr to fix
        zul/src/main/java/org/zkoss/zul/ListModelMap.java on lines 546..561

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

        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 (_set instanceof LinkedHashSet) {
                        //bug  1870996 Exception when use ListModelSet with SimpleListModelSharer
                        //java.lang.IndexOutOfBoundsException: 1, interval added index should be _set.size() - 1
                        final int i1 = _set.size() - 1;
                        fireEvent(ListDataEvent.INTERVAL_ADDED, i1, i1);
        Severity: Major
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.java and 1 other location - About 1 hr to fix
        zul/src/main/java/org/zkoss/zul/ListModelMap.java on lines 281..292

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

        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 (_set instanceof LinkedHashSet || _set instanceof SortedSet) {
                    // B60-ZK-1126.zul
                    // Remove all items may cause exception
                    return removePartial(c, true);
                } else { //bug #1839634 Problem while using HashSet with Databinding
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.java and 1 other location - About 1 hr to fix
        zul/src/main/java/org/zkoss/zul/ListModelSet.java on lines 336..345

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

        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 (_set instanceof LinkedHashSet || _set instanceof SortedSet) {
                    return removePartial(c, false);
                } else { //bug #1839634 Problem while using HashSet with Databinding
                    retainAllSelection(c);
                    final boolean ret = _set.retainAll(c);
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.java and 1 other location - About 1 hr to fix
        zul/src/main/java/org/zkoss/zul/ListModelSet.java on lines 317..328

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

        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

                    } else {
                        ++retained;
                        if (begin >= 0) {
                            fireEvent(ListDataEvent.INTERVAL_REMOVED, begin, index - 1);
                            index = begin; //this range removed, the index is reset to begin
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.java and 1 other location - About 40 mins to fix
        zul/src/main/java/org/zkoss/zul/ListModelMap.java on lines 462..469

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

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

            public void clear() {
                int i2 = _set.size() - 1;
                if (i2 < 0) {
                    return;
                }
        Severity: Major
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.java and 4 other locations - About 40 mins to fix
        zul/src/main/java/org/zkoss/zul/ListModelList.java on lines 212..220
        zul/src/main/java/org/zkoss/zul/ListModelMap.java on lines 218..226
        zul/src/main/java/org/zkoss/zul/ListModelMap.java on lines 536..544
        zul/src/main/java/org/zkoss/zul/ListModelMap.java on lines 742..750

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

        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

            public ListModelSet(E[] array) {
                _set = new LinkedHashSet<E>(array.length);
                for (int j = 0; j < array.length; ++j)
                    _set.add(array[j]);
            }
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.java and 1 other location - About 40 mins to fix
        zul/src/main/java/org/zkoss/zul/ListModelList.java on lines 100..104

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

            public boolean notifyChange(E element) {
                int i = indexOf(element);
                if (i >= 0) {
                    fireEvent(ListDataEvent.CONTENTS_CHANGED, i, i);
                    return true;
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/ListModelSet.java and 1 other location - About 35 mins to fix
        zul/src/main/java/org/zkoss/zul/ListModelArray.java on lines 142..149

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

        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