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

Summary

Maintainability
D
2 days
Test Coverage

Selectbox has 46 methods (exceeds 20 allowed). Consider refactoring.
Open

@SuppressWarnings("serial")
public class Selectbox extends HtmlBasedComponent implements Disable {

    private String _name;
    private boolean _disabled;
Severity: Minor
Found in zul/src/main/java/org/zkoss/zul/Selectbox.java - About 6 hrs to fix

    File Selectbox.java has 372 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Method render has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public String render(final Component owner, final Object data, final int index) {
                  final Selectbox self = (Selectbox) owner;
                  final Template tm = self.getTemplate("model");
                  if (tm == null)
                      return Objects.toString(data);
      Severity: Major
      Found in zul/src/main/java/org/zkoss/zul/Selectbox.java - About 2 hrs to fix

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

            @SuppressWarnings("unchecked")
            public void service(org.zkoss.zk.au.AuRequest request, boolean everError) {
                final String cmd = request.getCommand();
                if (cmd.equals(Events.ON_SELECT)) {
                    // ZK-2148: should check if model exists
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Selectbox.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 onInitRenderNow has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public void onInitRenderNow() {
                if (_model != null) {
                    _tmpdatas = new String[_model.getSize()];
                    final boolean old = _childable;
                    try {
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Selectbox.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 setModel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public void setModel(ListModel<?> model) {
                if (model != null) {
                    if (!(model instanceof Selectable))
                        throw new UiException(model.getClass() + " must implement " + Selectable.class);
        
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Selectbox.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 doSelectionChanged has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private void doSelectionChanged() {
                final Selectable<Object> smodel = getSelectableModel();
                if (smodel.isSelectionEmpty()) {
                    if (_jsel >= 0)
                        setSelectedIndex(-1);
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Selectbox.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 clone has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            @SuppressWarnings("rawtypes")
            public Object clone() {
                final Selectbox clone = (Selectbox) super.clone();
                if (clone._model != null) {
                    if (clone._model instanceof ComponentCloneListener) {
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Selectbox.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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                public String render(final Component owner, final Object data, final int index) {
                    final Selectbox self = (Selectbox) owner;
                    final Template tm = self.getTemplate("model");
                    if (tm == null)
                        return Objects.toString(data);
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Selectbox.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 19 locations. Consider refactoring.
        Open

            public void setName(String name) {
                if (name != null && name.length() == 0)
                    name = null;
                if (!Objects.equals(_name, name)) {
                    _name = name;
        Severity: Major
        Found in zul/src/main/java/org/zkoss/zul/Selectbox.java and 18 other locations - About 50 mins to fix
        zk/src/main/java/org/zkoss/zk/ui/HtmlBasedComponent.java on lines 323..330
        zul/src/main/java/org/zkoss/zul/Area.java on lines 110..117
        zul/src/main/java/org/zkoss/zul/Box.java on lines 129..136
        zul/src/main/java/org/zkoss/zul/Box.java on lines 185..192
        zul/src/main/java/org/zkoss/zul/Box.java on lines 250..257
        zul/src/main/java/org/zkoss/zul/Calendar.java on lines 237..244
        zul/src/main/java/org/zkoss/zul/Checkbox.java on lines 225..232
        zul/src/main/java/org/zkoss/zul/Grid.java on lines 1332..1339
        zul/src/main/java/org/zkoss/zul/Layout.java on lines 40..47
        zul/src/main/java/org/zkoss/zul/Listbox.java on lines 827..834
        zul/src/main/java/org/zkoss/zul/Listbox.java on lines 1483..1490
        zul/src/main/java/org/zkoss/zul/Radiogroup.java on lines 276..283
        zul/src/main/java/org/zkoss/zul/Script.java on lines 105..113
        zul/src/main/java/org/zkoss/zul/Script.java on lines 211..219
        zul/src/main/java/org/zkoss/zul/Slider.java on lines 375..382
        zul/src/main/java/org/zkoss/zul/Style.java on lines 119..126
        zul/src/main/java/org/zkoss/zul/Tabbox.java on lines 403..411
        zul/src/main/java/org/zkoss/zul/Tree.java on lines 819..826

        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

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

            static {
                addClientEvent(Selectbox.class, Events.ON_SELECT, CE_DUPLICATE_IGNORE | CE_IMPORTANT);
                addClientEvent(Selectbox.class, Events.ON_FOCUS, CE_DUPLICATE_IGNORE);
                addClientEvent(Selectbox.class, Events.ON_BLUR, CE_DUPLICATE_IGNORE);
            }
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Selectbox.java and 1 other location - About 35 mins to fix
        zul/src/main/java/org/zkoss/zul/Checkbox.java on lines 46..50

        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