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

Summary

Maintainability
F
3 days
Test Coverage

File Include.java has 408 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* Include.java

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

    Include has 37 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class Include extends XulElement implements Includer, DynamicPropertied, AfterCompose, IdSpace {
        private static final Logger log = LoggerFactory.getLogger(Include.class);
        private static final String ATTR_RENDERED = "org.zkoss.zul.Include.rendered";
        private String _src;
        private Map<String, Object> _dynams;
    Severity: Minor
    Found in zul/src/main/java/org/zkoss/zul/Include.java - About 4 hrs to fix

      Method renderProperties has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
              super.renderProperties(renderer);
      
              setChildPage(null);
              render(renderer, "comment", _comment);
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Include.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

      Method afterCompose has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public void afterCompose() {
              _afterComposed = true;
              fixModeOnly();
              if (_instantMode) {
                  final Execution exec = getExecution();
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Include.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 renderProperties has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
              super.renderProperties(renderer);
      
              setChildPage(null);
              render(renderer, "comment", _comment);
      Severity: Minor
      Found in zul/src/main/java/org/zkoss/zul/Include.java - About 2 hrs to fix

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

            private void fixModeOnly() { //called by afterCompose
                if ("auto".equals(_mode)) {
                    if (_src != null && !_progressing && !_localized) {
                        // according to the spec if query string exists, it should be defer
                        // mode automatically.
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Include.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 include has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            private void include(Writer out) throws IOException {
                final Desktop desktop = getDesktop();
                final Execution exec = getExecution();
                final String src = exec.toAbsoluteURI(_src, false);
                final Map<String, Object> old = setupDynams(exec);
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Include.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 include has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private void include(Writer out) throws IOException {
                final Desktop desktop = getDesktop();
                final Execution exec = getExecution();
                final String src = exec.toAbsoluteURI(_src, false);
                final Map<String, Object> old = setupDynams(exec);
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Include.java - About 1 hr to fix

          Method applyChangesToContent has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private void applyChangesToContent() {
                  if (_src == null) {
                      if (!getChildren().isEmpty())
                          getChildren().clear();
                      else if (!_instantMode && getChildPage() != null)
          Severity: Minor
          Found in zul/src/main/java/org/zkoss/zul/Include.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 afterCompose has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public void afterCompose() {
                  _afterComposed = true;
                  fixModeOnly();
                  if (_instantMode) {
                      final Execution exec = getExecution();
          Severity: Minor
          Found in zul/src/main/java/org/zkoss/zul/Include.java - About 1 hr to fix

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

                public void setMode(String mode) throws WrongValueException {
                    if (!_mode.equals(mode)) {
                        if (!"auto".equals(mode) && !"instant".equals(mode) && !"defer".equals(mode))
                            throw new WrongValueException("Unknown mode: " + mode);
                        if ((_localized || _progressing) && "instant".equals(mode))
            Severity: Minor
            Found in zul/src/main/java/org/zkoss/zul/Include.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 setLocalized has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public void setLocalized(boolean localized) {
                    if (_localized != localized) {
                        if (localized && "instant".equals(_mode))
                            throw new UnsupportedOperationException("localized not supported in instant mode yet");
            
            
            Severity: Minor
            Found in zul/src/main/java/org/zkoss/zul/Include.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 restoreDynams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private static void restoreDynams(Execution exec, Map<String, Object> old) {
                    if (old != null)
                        for (Map.Entry<String, Object> me : old.entrySet()) {
                            final String nm = me.getKey();
                            final Object val = me.getValue();
            Severity: Minor
            Found in zul/src/main/java/org/zkoss/zul/Include.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 setProgressing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public void setProgressing(boolean progressing) {
                    if (_progressing != progressing) {
                        if (progressing && "instant".equals(_mode))
                            throw new UnsupportedOperationException("progressing not allowed in instant mode");
            
            
            Severity: Minor
            Found in zul/src/main/java/org/zkoss/zul/Include.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 void setEnclosingTag(String tag) {
                    if (tag == null || tag.length() == 0)
                        throw new IllegalArgumentException();
                    if (!_tag.equals(tag)) {
                        _tag = tag;
            Severity: Minor
            Found in zul/src/main/java/org/zkoss/zul/Include.java and 1 other location - About 45 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/HtmlMacroComponent.java on lines 121..128

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

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

                        if (!"auto".equals(mode) && !"instant".equals(mode) && !"defer".equals(mode))
                            throw new WrongValueException("Unknown mode: " + mode);
            Severity: Major
            Found in zul/src/main/java/org/zkoss/zul/Include.java and 3 other locations - About 30 mins to fix
            zul/src/main/java/org/zkoss/zul/Datebox.java on lines 1038..1039
            zul/src/main/java/org/zkoss/zul/Splitter.java on lines 117..118
            zul/src/main/java/org/zkoss/zul/Toolbar.java on lines 74..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 40.

            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