sebastian-software/core

View on GitHub
source/class/core/apibrowser/Browser.js

Summary

Maintainability
F
3 days
Test Coverage

Function __onLoad has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

        __onLoad : function() {

            document.body.addEventListener('click', function(event) {

                var element = event.target;
Severity: Minor
Found in source/class/core/apibrowser/Browser.js - 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

Function __showContent has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

        __showContent: function(data, doToggle) {

            if (data.file) {

                var content = document.getElementById('content'),
Severity: Minor
Found in source/class/core/apibrowser/Browser.js - 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

File Browser.js has 308 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
==================================================================================================
  API Browser
  Copyright 2012 Zynga Inc.
  Copyright 2012-2014 Sebastian Werner
Severity: Minor
Found in source/class/core/apibrowser/Browser.js - About 3 hrs to fix

    Function __treeWalker has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

            __treeWalker: function(node, base) {
    
                var html = '';
    
                var filter = function(value) {
    Severity: Minor
    Found in source/class/core/apibrowser/Browser.js - 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

    Function __showContent has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            __showContent: function(data, doToggle) {
    
                if (data.file) {
    
                    var content = document.getElementById('content'),
    Severity: Major
    Found in source/class/core/apibrowser/Browser.js - About 2 hrs to fix

      Function __onLoad has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              __onLoad : function() {
      
                  document.body.addEventListener('click', function(event) {
      
                      var element = event.target;
      Severity: Minor
      Found in source/class/core/apibrowser/Browser.js - About 1 hr to fix

        Function construct has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            construct: function()
            {
                this.__headElem = document.createElement("div");
                this.__headElem.id = "head";
                this.__headElem.innerHTML = "API Documentation";
        Severity: Minor
        Found in source/class/core/apibrowser/Browser.js - About 1 hr to fix

          Function callback has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                  callback: function(data, id) {
          
                      if (core.String.endsWith(id, ".mustache")) {
          
                          var templateName = id.substring(0, id.indexOf(".mustache"));
          Severity: Minor
          Found in source/class/core/apibrowser/Browser.js - 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

          Function __treeWalker has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  __treeWalker: function(node, base) {
          
                      var html = '';
          
                      var filter = function(value) {
          Severity: Minor
          Found in source/class/core/apibrowser/Browser.js - About 1 hr to fix

            Function __showTree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    __showTree: function(data) {
            
                        if (!data.file) {
                            return;
                        }
            Severity: Minor
            Found in source/class/core/apibrowser/Browser.js - 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

            Avoid deeply nested control flow statements.
            Open

                                        if (href.charAt(0) === '#') {
                                            this.open(href.slice(1));
                                        } else {
                                            return;
                                        }
            Severity: Major
            Found in source/class/core/apibrowser/Browser.js - About 45 mins to fix

              Function buildHash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      buildHash: function(type, file, item) {
              
                          type = type || null;
                          file = file || null;
                          item = item || null;
              Severity: Minor
              Found in source/class/core/apibrowser/Browser.js - 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

              Function parseHash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      parseHash: function(hash) {
              
                          var regex = new RegExp("((source|static|member|property|event)\:)?([A-Za-z0-9_\.]+)?(\~([A-Za-z0-9_]+))");
                          var tmp = unescape(hash).split(regex);
              
              
              Severity: Minor
              Found in source/class/core/apibrowser/Browser.js - 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

                                          content.innerHTML = this.__tmpl.error.render({
                                              name: '404 - Not Found',
                                              description: 'The selected file "' + data.file + '" was not found.'
                                          }, this.__tmpl);
              Severity: Major
              Found in source/class/core/apibrowser/Browser.js and 1 other location - About 1 hr to fix
              source/class/core/apibrowser/Browser.js on lines 435..438

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

              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

                                  content.innerHTML = this.__tmpl.error.render({
                                      name: '404 - Not Found',
                                      description: 'The selected File "' + data.file + '" was not found.'
                                  }, this.__tmpl);
              Severity: Major
              Found in source/class/core/apibrowser/Browser.js and 1 other location - About 1 hr to fix
              source/class/core/apibrowser/Browser.js on lines 420..423

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

              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 (var e = 0; e < oldElements.length; e++) {
                                  core.bom.ClassName.remove(oldElements[e], 'active');
                              }
              Severity: Minor
              Found in source/class/core/apibrowser/Browser.js and 1 other location - About 50 mins to fix
              source/class/core/apibrowser/Browser.js on lines 377..379

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

              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 (var o = 0; o < oldElements.length; o++) {
                              core.bom.ClassName.remove(oldElements[o], 'active');
                          }
              Severity: Minor
              Found in source/class/core/apibrowser/Browser.js and 1 other location - About 50 mins to fix
              source/class/core/apibrowser/Browser.js on lines 486..488

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

              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