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

Summary

Maintainability
F
3 days
Test Coverage

Method init has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    public void init(Object context, Configuration config) {
        if (_config != null)
            throw new IllegalStateException("Cannot be initialized twice");
        if (config == null)
            throw new IllegalArgumentException("null");
Severity: Minor
Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.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

AbstractWebApp has 32 methods (exceeds 20 allowed). Consider refactoring.
Open

public abstract class AbstractWebApp implements WebApp, WebAppCtrl {
    private static final Logger log = LoggerFactory.getLogger(AbstractWebApp.class);

    private String _appnm;
    private Configuration _config;
Severity: Minor
Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java - About 4 hrs to fix

    File AbstractWebApp.java has 331 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Method init has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public void init(Object context, Configuration config) {
              if (_config != null)
                  throw new IllegalStateException("Cannot be initialized twice");
              if (config == null)
                  throw new IllegalArgumentException("null");
      Severity: Major
      Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java - About 3 hrs to fix

        Method loadBuild has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public static synchronized String loadBuild() {
                if (_build == null) {
                    final String FILE = "/metainfo/zk/build";
                    ClassLoader cl = Thread.currentThread().getContextClassLoader();
                    InputStream is = null;
        Severity: Minor
        Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.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 destroy has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public void destroy() {
                try {
                    _config.invokeWebAppCleanups();
                } catch (Throwable ex) {
                    ex.printStackTrace(); //not using log since it might be cleaned up
        Severity: Minor
        Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java - About 1 hr to fix

          Method destroy has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              public void destroy() {
                  try {
                      _config.invokeWebAppCleanups();
                  } catch (Throwable ex) {
                      ex.printStackTrace(); //not using log since it might be cleaned up
          Severity: Minor
          Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.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 loadBuild has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static synchronized String loadBuild() {
                  if (_build == null) {
                      final String FILE = "/metainfo/zk/build";
                      ClassLoader cl = Thread.currentThread().getContextClassLoader();
                      InputStream is = null;
          Severity: Minor
          Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java - About 1 hr to fix

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

                    if (cls == null) {
                        _engine = new UiEngineImpl();
                    } else {
                        try {
                            _engine = (UiEngine) cls.newInstance();
            Severity: Major
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 3 other locations - About 45 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 149..157
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 160..168
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 188..196

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

            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

                    if (cls == null) {
                        _factory = new SimpleUiFactory();
                    } else {
                        try {
                            _factory = (UiFactory) cls.newInstance();
            Severity: Major
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 3 other locations - About 45 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 138..146
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 149..157
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 188..196

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

            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

                    if (cls == null) {
                        _sesscache = new SimpleSessionCache();
                    } else {
                        try {
                            _sesscache = (SessionCache) cls.newInstance();
            Severity: Major
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 3 other locations - About 45 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 138..146
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 149..157
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 160..168

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

            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

                    if (cls == null) {
                        _provider = new SessionDesktopCacheProvider();
                    } else {
                        try {
                            _provider = (DesktopCacheProvider) cls.newInstance();
            Severity: Major
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 3 other locations - About 45 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 138..146
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 160..168
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 188..196

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

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

                    if (cls != null) {
                        try {
                            _audec = (AuDecoder) cls.newInstance();
                        } catch (Exception ex) {
                            throw UiException.Aide.wrap(ex, "Unable to construct " + cls);
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 2 other locations - About 35 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 171..177
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 179..185

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

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

                    if (cls != null) {
                        try {
                            _idgen = (IdGenerator) cls.newInstance();
                        } catch (Exception ex) {
                            throw UiException.Aide.wrap(ex, "Unable to construct " + cls);
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 2 other locations - About 35 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 171..177
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 199..205

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

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

                    if (cls != null) {
                        try {
                            _failover = (FailoverManager) cls.newInstance();
                        } catch (Exception ex) {
                            throw UiException.Aide.wrap(ex, "Unable to construct " + cls);
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 2 other locations - About 35 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 179..185
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 199..205

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

            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

                public void setSessionCache(SessionCache cache) {
                    if (cache == null)
                        throw new IllegalArgumentException();
                    _sesscache.destroy(this);
                    _sesscache = cache;
            Severity: Major
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 3 other locations - About 30 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 279..285
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 295..301
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 307..313

            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

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

                public void setUiFactory(UiFactory factory) {
                    if (factory == null)
                        throw new IllegalArgumentException();
                    _factory.stop(this);
                    _factory = factory;
            Severity: Major
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 3 other locations - About 30 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 279..285
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 295..301
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 339..345

            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

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

                public void setUiEngine(UiEngine engine) {
                    if (engine == null)
                        throw new IllegalArgumentException();
                    _engine.stop(this);
                    _engine = engine;
            Severity: Major
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 3 other locations - About 30 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 295..301
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 307..313
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 339..345

            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

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

                public void setDesktopCacheProvider(DesktopCacheProvider provider) {
                    if (provider == null)
                        throw new IllegalArgumentException();
                    _provider.stop(this);
                    _provider = provider;
            Severity: Major
            Found in zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java and 3 other locations - About 30 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 279..285
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 307..313
            zk/src/main/java/org/zkoss/zk/ui/impl/AbstractWebApp.java on lines 339..345

            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