src/_helpers/developer.ts

Summary

Maintainability
F
5 days
Test Coverage

File developer.ts has 480 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as $ from 'jquery';

/**
 * Developer tools, press 0 (by default) key four times to display developer tools
 * You can see console logs in special layer in the app.
Severity: Minor
Found in src/_helpers/developer.ts - About 7 hrs to fix

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

        onKeyDown(keyCode, event, fromRC) {
            const scope = this;
            if (this.isActive) {
                if (document.activeElement && document.activeElement.nodeName === 'INPUT') {
                    alert('000');
    Severity: Minor
    Found in src/_helpers/developer.ts - 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 appendUIStyles has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        appendUIStyles() {
            let s = document.createElement('style');
            let cssText = "\
    #developer-ui {\
    position: absolute;\
    Severity: Major
    Found in src/_helpers/developer.ts - About 2 hrs to fix

      Function polyfillConsole has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          polyfillConsole() {
              const scope = this;
      
              if (typeof window.console === 'undefined') {
                  (<any>window).console = <Console>({
      Severity: Major
      Found in src/_helpers/developer.ts - About 2 hrs to fix

        Developer has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export default class Developer {
        
            config = {
                debug: true,
                /**
        Severity: Minor
        Found in src/_helpers/developer.ts - About 2 hrs to fix

          Function onKeyDown has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              onKeyDown(keyCode, event, fromRC) {
                  const scope = this;
                  if (this.isActive) {
                      if (document.activeElement && document.activeElement.nodeName === 'INPUT') {
                          alert('000');
          Severity: Minor
          Found in src/_helpers/developer.ts - About 2 hrs to fix

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

                polyfillConsole() {
                    const scope = this;
            
                    if (typeof window.console === 'undefined') {
                        (<any>window).console = <Console>({
            Severity: Minor
            Found in src/_helpers/developer.ts - 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 toConsole has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                toConsole(type, args) {
                    let line, t;
            
                    args = Array.prototype.slice.apply(args);
            
            
            Severity: Minor
            Found in src/_helpers/developer.ts - 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 constructor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                constructor(config) {
                    let onerror, scope = this;
            
                    this.canAccessError = this.isErrorAvailable();
                    this.configure(config);
            Severity: Minor
            Found in src/_helpers/developer.ts - About 1 hr to fix

              Function getTextValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  getTextValue(keycode) {
                      if (keycode === this.key.ONE || keycode === 1) {
                          return '1';
                      } else if (keycode === this.key.TWO || keycode === 2) {
                          return '2';
              Severity: Minor
              Found in src/_helpers/developer.ts - 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 updateNotifications has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  updateNotifications() {
                      let errors = 0, networkErrors = 0;
              
                      for (let i in this.consoleStack) {
                          if (this.consoleStack[i].isError) {
              Severity: Minor
              Found in src/_helpers/developer.ts - 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 toConsole has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  toConsole(type, args) {
                      let line, t;
              
                      args = Array.prototype.slice.apply(args);
              
              
              Severity: Minor
              Found in src/_helpers/developer.ts - About 1 hr to fix

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

                    constructor(config) {
                        let onerror, scope = this;
                
                        this.canAccessError = this.isErrorAvailable();
                        this.configure(config);
                Severity: Minor
                Found in src/_helpers/developer.ts - 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

                Avoid too many return statements within this function.
                Open

                            return '8';
                Severity: Major
                Found in src/_helpers/developer.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return '6';
                  Severity: Major
                  Found in src/_helpers/developer.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return '9';
                    Severity: Major
                    Found in src/_helpers/developer.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return '5';
                      Severity: Major
                      Found in src/_helpers/developer.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                            return false;
                        Severity: Major
                        Found in src/_helpers/developer.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return '0';
                          Severity: Major
                          Found in src/_helpers/developer.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return '7';
                            Severity: Major
                            Found in src/_helpers/developer.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                                  return false;
                              Severity: Major
                              Found in src/_helpers/developer.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return null;
                                Severity: Major
                                Found in src/_helpers/developer.ts - About 30 mins to fix

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

                                          if (networkErrors > 0 && this.$elNetworkErrors) {
                                              this.$elNetworkErrors.text(networkErrors).show();
                                  
                                          } else if (this.$elNetworkErrors) {
                                              this.$elNetworkErrors.text('0').hide();
                                  Severity: Major
                                  Found in src/_helpers/developer.ts and 1 other location - About 2 hrs to fix
                                  src/_helpers/developer.ts on lines 596..601

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

                                  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

                                          if (errors > 0 && this.$elErrors) {
                                              this.$elErrors.text(errors).show();
                                  
                                          } else if (this.$elErrors) {
                                              this.$elErrors.text('0').hide();
                                  Severity: Major
                                  Found in src/_helpers/developer.ts and 1 other location - About 2 hrs to fix
                                  src/_helpers/developer.ts on lines 603..608

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

                                  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

                                          (<any>window).console.info = function () {
                                              scope.toConsole('info', arguments);
                                              return (<any>window).console.__info.apply(window.console, arguments);
                                          };
                                  Severity: Major
                                  Found in src/_helpers/developer.ts and 3 other locations - About 1 hr to fix
                                  src/_helpers/developer.ts on lines 209..212
                                  src/_helpers/developer.ts on lines 219..222
                                  src/_helpers/developer.ts on lines 224..227

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

                                  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

                                          (<any>window).console.warn = function () {
                                              scope.toConsole('warn', arguments);
                                              return (<any>window).console.__warn.apply(window.console, arguments);
                                          };
                                  Severity: Major
                                  Found in src/_helpers/developer.ts and 3 other locations - About 1 hr to fix
                                  src/_helpers/developer.ts on lines 214..217
                                  src/_helpers/developer.ts on lines 219..222
                                  src/_helpers/developer.ts on lines 224..227

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

                                  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

                                          (<any>window).console.error = function () {
                                              scope.toConsole('error', arguments);
                                              return (<any>window).console.__error.apply(window.console, arguments);
                                          };
                                  Severity: Major
                                  Found in src/_helpers/developer.ts and 3 other locations - About 1 hr to fix
                                  src/_helpers/developer.ts on lines 209..212
                                  src/_helpers/developer.ts on lines 214..217
                                  src/_helpers/developer.ts on lines 224..227

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

                                  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

                                          (<any>window).console.network = function () {
                                              scope.toConsole('error', arguments);
                                              return (<any>window).console.__error.apply(window.console, arguments);
                                          };
                                  Severity: Major
                                  Found in src/_helpers/developer.ts and 3 other locations - About 1 hr to fix
                                  src/_helpers/developer.ts on lines 209..212
                                  src/_helpers/developer.ts on lines 214..217
                                  src/_helpers/developer.ts on lines 219..222

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

                                  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