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

Summary

Maintainability
D
2 days
Test Coverage

Tab has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

@SuppressWarnings("serial")
public class Tab extends LabelImageElement {

    private static final Logger log = LoggerFactory.getLogger(Tab.class);

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

    File Tab.java has 280 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Method service has 46 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_SELECT)) {
                  final Tabbox tabbox = getTabbox();
                  final Set<Tab> prevSeldItems = new LinkedHashSet<Tab>();
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Tab.java - About 1 hr to fix

        Method service has a Cognitive Complexity of 9 (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_SELECT)) {
                    final Tabbox tabbox = getTabbox();
                    final Set<Tab> prevSeldItems = new LinkedHashSet<Tab>();
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.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 close has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public void close() {
                if (_selected) {
                    final Tab tab = selectNextTab();
                    if (tab != null) {
                        final Set<Tab> selItems = new HashSet<Tab>(2);
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.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 beforeChildAdded has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public void beforeChildAdded(Component child, Component refChild) {
                if (child instanceof Caption) {
                    if (_caption != null && _caption != child)
                        throw new UiException("Only one caption is allowed: " + this);
                    super.beforeChildAdded(child, refChild);
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.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 getLinkedPanel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public Tabpanel getLinkedPanel() {
                final int j = getIndex();
                if (j >= 0) {
                    final Tabbox tabbox = getTabbox();
                    if (tabbox != null) {
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.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 selectNextTab has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private Tab selectNextTab() {
                for (Tab tab = (Tab) getNextSibling(); tab != null; tab = (Tab) tab.getNextSibling())
                    if (!tab.isDisabled()) {
                        tab.setSelected(true);
                        return tab;
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.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

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

            public boolean insertBefore(Component child, Component refChild) {
                if (child instanceof Caption) {
                    refChild = getFirstChild();
                    //always makes caption as the first child
                    if (super.insertBefore(child, refChild)) {
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.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 Tabpanel getLinkedPanel() {
                final int j = getIndex();
                if (j >= 0) {
                    final Tabbox tabbox = getTabbox();
                    if (tabbox != null) {
        Severity: Major
        Found in zul/src/main/java/org/zkoss/zul/Tab.java and 1 other location - About 1 hr to fix
        zul/src/main/java/org/zkoss/zul/Tabpanel.java on lines 44..55

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

        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 int getIndex() {
                final Tabs tabs = (Tabs) getParent();
                if (tabs == null)
                    return -1;
                int j = 0;
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.java and 1 other location - About 55 mins to fix
        zul/src/main/java/org/zkoss/zul/Tabpanel.java on lines 67..75

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

        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

                                    if (model == null || items.size() < 1)
                                        return null;
                                    else {
                                        Set<Object> s = new LinkedHashSet<Object>();
                                        s.add(model.getElementAt(((Tab) items.iterator().next()).getIndex()));
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.java and 1 other location - About 50 mins to fix
        zul/src/main/java/org/zkoss/zul/Combobox.java on lines 1071..1077

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

        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

            private void afterUnmarshal() {
                for (Iterator<Component> it = getChildren().iterator(); it.hasNext();) {
                    final Object child = it.next();
                    if (child instanceof Caption) {
                        _caption = (Caption) child;
        Severity: Major
        Found in zul/src/main/java/org/zkoss/zul/Tab.java and 3 other locations - About 40 mins to fix
        zul/src/main/java/org/zkoss/zul/LayoutRegion.java on lines 528..536
        zul/src/main/java/org/zkoss/zul/Row.java on lines 334..342
        zul/src/main/java/org/zkoss/zul/Window.java on lines 987..995

        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

                for (Tab tab = (Tab) getPreviousSibling(); tab != null; tab = (Tab) tab.getPreviousSibling())
                    if (!tab.isDisabled()) {
                        tab.setSelected(true);
                        return tab;
                    }
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.java and 1 other location - About 40 mins to fix
        zul/src/main/java/org/zkoss/zul/Tab.java on lines 190..194

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

        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

                for (Tab tab = (Tab) getNextSibling(); tab != null; tab = (Tab) tab.getNextSibling())
                    if (!tab.isDisabled()) {
                        tab.setSelected(true);
                        return tab;
                    }
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.java and 1 other location - About 40 mins to fix
        zul/src/main/java/org/zkoss/zul/Tab.java on lines 195..199

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

        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

                if (child instanceof Caption) {
                    refChild = getFirstChild();
                    //always makes caption as the first child
                    if (super.insertBefore(child, refChild)) {
                        _caption = (Caption) child;
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Tab.java and 1 other location - About 35 mins to fix
        zul/src/main/java/org/zkoss/zul/LayoutRegion.java on lines 440..449

        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