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

Summary

Maintainability
D
2 days
Test Coverage

Method setSelectAll has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

        public void setSelectAll(boolean selectAll) {
            if (selectAll) {
                boolean isGroupSelectable = model.isGroupSelectable();
                List<E> all = new LinkedList<>();
                for (int i = 0, j = model.getGroupCount(); i < j; i++) {
Severity: Minor
Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.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 isSelectAll has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

        public boolean isSelectAll() {
            Selectable smodel = (Selectable) model;
            boolean isGroupSelectable = model.isGroupSelectable();
            for (int i = 0, j = model.getGroupCount(); i < j; i++) {
                if (isGroupSelectable) {
Severity: Minor
Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java - About 4 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

AbstractGroupsModel has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

public abstract class AbstractGroupsModel<D, H, F, E>
        implements GroupsModel<D, H, F>, GroupsSelectableModel<E>, java.io.Serializable {
    private transient List<GroupsDataListener> _listeners = new LinkedList<GroupsDataListener>();

    /** The current selection. */
Severity: Minor
Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java - About 2 hrs to fix

    Method setSelectAll has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public void setSelectAll(boolean selectAll) {
                if (selectAll) {
                    boolean isGroupSelectable = model.isGroupSelectable();
                    List<E> all = new LinkedList<>();
                    for (int i = 0, j = model.getGroupCount(); i < j; i++) {
    Severity: Minor
    Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java - About 1 hr to fix

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

              public boolean isSelectAll() {
                  Selectable smodel = (Selectable) model;
                  boolean isGroupSelectable = model.isGroupSelectable();
                  for (int i = 0, j = model.getGroupCount(); i < j; i++) {
                      if (isGroupSelectable) {
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                    if (isSelectable((E) child)) {
                                        all.add((E) child);
                                    }
        Severity: Major
        Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if (isSelectable((E) group)) {
                                          all.add((E) group);
                                      }
          Severity: Major
          Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java - About 45 mins to fix

            Avoid too many return statements within this method.
            Open

                        return true;
            Severity: Major
            Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java - About 30 mins to fix

              Method setSelection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public void setSelection(Collection<? extends E> selection) {
                      if (!_selection.equals(selection)) {
                          if (!_multiple && _selection.size() > 1)
                              throw new IllegalArgumentException("Only one selection is allowed, not " + selection);
                          _selection.clear();
              Severity: Minor
              Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.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

                                  for (int childIndex = 0, childSize = model.getChildCount(i); childIndex < childSize; childIndex++) {
                                      Object child = model.getChild(i, childIndex);
                                      if (isSelectable((E) child) && !smodel.isSelected(child)) {
                                          return false;
                                      }
              Severity: Minor
              Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java and 1 other location - About 55 mins to fix
              zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java on lines 305..310

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

              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

                                  for (int childIndex = 0, childSize = model.getChildCount(i); childIndex < childSize; childIndex++) {
                                      Object child = model.getChild(i, childIndex);
                                      if (isSelectable((E) child) && !smodel.isSelected(child)) {
                                          return false;
                                      }
              Severity: Minor
              Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java and 1 other location - About 55 mins to fix
              zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java on lines 318..323

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

              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

                                      for (int childIndex = 0, childSize = model
                                              .getChildCount(i); childIndex < childSize; childIndex++) {
                                          Object child = model.getChild(i, childIndex);
                                          if (isSelectable((E) child)) {
                                              all.add((E) child);
              Severity: Minor
              Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java and 1 other location - About 50 mins to fix
              zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java on lines 274..280

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

              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

                                      for (int childIndex = 0, childSize = model
                                              .getChildCount(i); childIndex < childSize; childIndex++) {
                                          Object child = model.getChild(i, childIndex);
                                          if (isSelectable((E) child)) {
                                              all.add((E) child);
              Severity: Minor
              Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java and 1 other location - About 50 mins to fix
              zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java on lines 260..266

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

              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 addToSelection(E obj) {
                      if (_selection.add(obj)) {
                          if (!_multiple) {
                              _selection.clear();
                              _selection.add(obj);
              Severity: Minor
              Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java and 1 other location - About 40 mins to fix
              zul/src/main/java/org/zkoss/zul/AbstractListModel.java on lines 135..145

              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

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

                  protected void fireEvent(int type, int groupIndex, int index0, int index1) {
                      final GroupsDataEvent evt = new GroupsDataEvent(this, type, groupIndex, index0, index1);
                      for (GroupsDataListener l : _listeners)
                          l.onChange(evt);
                  }
              Severity: Minor
              Found in zul/src/main/java/org/zkoss/zul/AbstractGroupsModel.java and 1 other location - About 30 mins to fix
              zul/src/main/java/org/zkoss/zul/AbstractTreeModel.java on lines 180..184

              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