zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java

Summary

Maintainability
F
4 days
Test Coverage

AbstractExecution has 74 methods (exceeds 20 allowed). Consider refactoring.
Open

public abstract class AbstractExecution implements Execution, ExecutionCtrl {
    private static final Logger _zklog = LoggerFactory.getLogger("org.zkoss.zk.log");

    private Desktop _desktop;
    private Page _curpage;
Severity: Major
Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 1 day to fix

    File AbstractExecution.java has 487 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* AbstractExecution.java
    
        Purpose:
            
        Description:
    Severity: Minor
    Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 7 hrs to fix

      Method getExtraXelVariable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public Object getExtraXelVariable(XelContext ctx, Object base, Object name) {
              //Note this method searches only _resolvers
              if (_resolvers != null) {
                  for (Iterator it = CollectionsX.comodifiableIterator(_resolvers); it.hasNext();) {
                      final VariableResolver vr = (VariableResolver) it.next();
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.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 setAttribute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public Object setAttribute(String name, Object value, boolean recurse) {
              if (recurse && !hasAttribute(name)) {
                  Desktop desktop = getDesktop();
                  if (desktop != null) {
                      if (desktop.hasAttribute(name, true))
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.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 removeAttribute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public Object removeAttribute(String name, boolean recurse) {
              if (recurse && !hasAttribute(name)) {
                  Desktop desktop = getDesktop();
                  if (desktop != null) {
                      if (desktop.hasAttribute(name, true))
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.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 toAbsoluteURI has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public String toAbsoluteURI(String uri, boolean skipInclude) {
              if (uri != null && uri.length() > 0) {
                  final char cc = uri.charAt(0);
                  if (cc != '/' && cc != '~' && !(skipInclude && isIncluded()) && !Servlets.isUniversalURL(uri)) {
                      final String dir = getDesktop().getCurrentDirectory();
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.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 createComponentsDirectly0 has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private Component createComponentsDirectly0(Document content, String ext, Component parent, Component insertBefore,
                  VariableResolver resolver, Map<?, ?> arg) {
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 45 mins to fix

        Method createComponentsDirectly0 has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private Component createComponentsDirectly0(String content, String ext, Component parent, Component insertBefore,
                    VariableResolver resolver, Map<?, ?> arg) {
        Severity: Minor
        Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 45 mins to fix

          Method createComponentsDirectly0 has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private Component createComponentsDirectly0(Reader reader, String ext, Component parent, Component insertBefore,
                      VariableResolver resolver, Map<?, ?> arg) throws IOException {
          Severity: Minor
          Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 45 mins to fix

            Method createComponentsDirectly has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public Component createComponentsDirectly(String content, String ext, Component parent, Component insertBefore,
                        VariableResolver resolver) {
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 35 mins to fix

              Method createComponents has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public Component[] createComponents(String uri, Component parent, Component insertBefore, VariableResolver resolver,
                          Map<?, ?> arg) {
              Severity: Minor
              Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 35 mins to fix

                Method createComponents0 has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private Component createComponents0(String uri, Component parent, Component insertBefore, VariableResolver resolver,
                            Map<?, ?> arg) {
                Severity: Minor
                Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 35 mins to fix

                  Method createComponentsDirectly has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public Component createComponentsDirectly(Reader reader, String ext, Component parent, Component insertBefore,
                              VariableResolver resolver) throws IOException {
                  Severity: Minor
                  Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 35 mins to fix

                    Method createComponents0 has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        private Component createComponents0(PageDefinition pagedef, Component parent, Component insertBefore,
                                VariableResolver resolver, Map<?, ?> arg) {
                    Severity: Minor
                    Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 35 mins to fix

                      Method createComponentsDirectly has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public Component createComponentsDirectly(Document content, String ext, Component parent, Component insertBefore,
                                  VariableResolver resolver) {
                      Severity: Minor
                      Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java - About 35 mins to fix

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

                            public void sendRedirect(String uri, boolean respRedirect) {
                                if (!respRedirect) {
                                    sendRedirect(uri);
                                    return;
                                } else {
                        Severity: Minor
                        Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.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 onActivate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            @SuppressWarnings("unchecked")
                            public void onActivate() {
                                if (_desktop != null) {
                                    List<Callback> callbacks = (List<Callback>) _desktop.getAttribute(Add_ON_ACTIVATE);
                                    if (callbacks != null) {
                        Severity: Minor
                        Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.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 onBeforeDeactivate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            @SuppressWarnings("unchecked")
                            public void onBeforeDeactivate() {
                                if (_desktop != null) {
                                    List<Callback> callbacks = (List<Callback>) _desktop.getAttribute(Add_ON_DEACTIVATE);
                                    if (callbacks != null) {
                        Severity: Minor
                        Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.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 hasVariableResolver has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public boolean hasVariableResolver(Class<? extends VariableResolver> cls) {
                                if (_resolvers != null)
                                    for (final VariableResolver resolver : _resolvers)
                                        if (cls.isInstance(resolver))
                                            return true;
                        Severity: Minor
                        Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.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 void addOnActivate(Callback callback) {
                                Execution exec = Executions.getCurrent();
                                if (exec == null)
                                    throw new IllegalStateException("Execution cannot be null!");
                                Desktop desktop = exec.getDesktop();
                        zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java on lines 600..613

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

                        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 void addOnDeactivate(Callback callback) {
                                Execution exec = Executions.getCurrent();
                                if (exec == null)
                                    throw new IllegalStateException("Execution cannot be null!");
                                Desktop desktop = exec.getDesktop();
                        zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java on lines 579..592

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

                        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

                            @SuppressWarnings("unchecked")
                            public void onActivate() {
                                if (_desktop != null) {
                                    List<Callback> callbacks = (List<Callback>) _desktop.getAttribute(Add_ON_ACTIVATE);
                                    if (callbacks != null) {
                        zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java on lines 258..270

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

                        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

                            @SuppressWarnings("unchecked")
                            public void onBeforeDeactivate() {
                                if (_desktop != null) {
                                    List<Callback> callbacks = (List<Callback>) _desktop.getAttribute(Add_ON_DEACTIVATE);
                                    if (callbacks != null) {
                        zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java on lines 244..256

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

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

                            private Component createComponentsDirectly0(String content, String ext, Component parent, Component insertBefore,
                                    VariableResolver resolver, Map<?, ?> arg) {
                                final Component[] cs = getUiEngine().createComponents(this, getPageDefinitionDirectly(content, ext),
                                        getCurrentPage(), parent, insertBefore, resolver, arg);
                                return cs.length > 0 ? cs[0] : null;
                        Severity: Major
                        Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java and 2 other locations - About 45 mins to fix
                        zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java on lines 406..411
                        zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java on lines 413..418

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

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

                            private Component createComponentsDirectly0(Reader reader, String ext, Component parent, Component insertBefore,
                                    VariableResolver resolver, Map<?, ?> arg) throws IOException {
                                final Component[] cs = getUiEngine().createComponents(this, getPageDefinitionDirectly(reader, ext),
                                        getCurrentPage(), parent, insertBefore, resolver, arg);
                                return cs.length > 0 ? cs[0] : null;
                        Severity: Major
                        Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java and 2 other locations - About 45 mins to fix
                        zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java on lines 399..404
                        zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java on lines 406..411

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

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

                            private Component createComponentsDirectly0(Document content, String ext, Component parent, Component insertBefore,
                                    VariableResolver resolver, Map<?, ?> arg) {
                                final Component[] cs = getUiEngine().createComponents(this, getPageDefinitionDirectly(content, ext),
                                        getCurrentPage(), parent, insertBefore, resolver, arg);
                                return cs.length > 0 ? cs[0] : null;
                        Severity: Major
                        Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java and 2 other locations - About 45 mins to fix
                        zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java on lines 399..404
                        zk/src/main/java/org/zkoss/zk/ui/impl/AbstractExecution.java on lines 413..418

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

                        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