CMSgov/dpc-app

View on GitHub
dpc-admin/app/assets/javascripts/components/_accordions.js

Summary

Maintainability
F
1 wk
Test Coverage

Function 1 has a Cognitive Complexity of 109 (exceeds 5 allowed). Consider refactoring.
Open

(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";

/*
 * classList.js: Cross-browser full element.classList implementation.
Severity: Minor
Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 2 days 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 _accordions.js has 572 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";

/*
 * classList.js: Cross-browser full element.classList implementation.
Severity: Major
Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 1 day to fix

    Function 1 has 166 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
    "use strict";
    
    /*
     * classList.js: Cross-browser full element.classList implementation.
    Severity: Major
    Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 6 hrs to fix

      Function 4 has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

      },{}],4:[function(require,module,exports){
      /*
      object-assign
      (c) Sindre Sorhus
      @license MIT
      Severity: Minor
      Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 6 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 5 has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      },{}],5:[function(require,module,exports){
      'use strict';
      
      var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
      
      
      Severity: Minor
      Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 3 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 3 has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      },{}],3:[function(require,module,exports){
      'use strict';
      
      // element-closest | CC0-1.0 | github.com/jonathantneal/closest
      
      
      Severity: Minor
      Found in dpc-admin/app/assets/javascripts/components/_accordions.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 4 has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      },{}],4:[function(require,module,exports){
      /*
      object-assign
      (c) Sindre Sorhus
      @license MIT
      Severity: Major
      Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 2 hrs to fix

        Function 9 has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        },{"../compose":6,"../delegate":7}],9:[function(require,module,exports){
        'use strict';
        
        function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
        
        
        Severity: Major
        Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 2 hrs to fix

          Function 5 has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          },{}],5:[function(require,module,exports){
          'use strict';
          
          var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
          
          
          Severity: Major
          Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

              if (!("classList" in document.createElement("_")) || document.createElementNS && !("classList" in document.createElementNS("http://www.w3.org/2000/svg", "g"))) {
            
                (function (view) {
            
                  "use strict";
            Severity: Critical
            Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 1 hr to fix

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

              },{"../compose":6,"../delegate":7}],9:[function(require,module,exports){
              'use strict';
              
              function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
              
              
              Severity: Minor
              Found in dpc-admin/app/assets/javascripts/components/_accordions.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 18 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              },{}],18:[function(require,module,exports){
              'use strict';
              
              var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
              
              
              Severity: Minor
              Found in dpc-admin/app/assets/javascripts/components/_accordions.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 shouldUseNative has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function shouldUseNative() {
                try {
                  if (!Object.assign) {
                    return false;
                  }
              Severity: Minor
              Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 1 hr to fix

                Function getListeners has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                var getListeners = function getListeners(type, handler) {
                  var match = type.match(DELEGATE_PATTERN);
                  var selector;
                  if (match) {
                    type = match[1];
                Severity: Minor
                Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                    if (typeof ElementProto.matches !== 'function') {
                      ElementProto.matches = ElementProto.msMatchesSelector || ElementProto.mozMatchesSelector || ElementProto.webkitMatchesSelector || function matches(selector) {
                        var element = this;
                        var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
                        var index = 0;
                  Severity: Major
                  Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 40 mins to fix

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

                    },{}],19:[function(require,module,exports){
                    'use strict';
                    
                    var EXPANDED = 'aria-expanded';
                    var CONTROLS = 'aria-controls';
                    Severity: Minor
                    Found in dpc-admin/app/assets/javascripts/components/_accordions.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 17 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    },{"object-assign":4,"receptor/behavior":5}],17:[function(require,module,exports){
                    "use strict";
                    
                    // https://stackoverflow.com/a/7557433
                    function isElementInViewport(el) {
                    Severity: Minor
                    Found in dpc-admin/app/assets/javascripts/components/_accordions.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

                    Avoid too many return statements within this function.
                    Open

                        return true;
                    Severity: Major
                    Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return false;
                      Severity: Major
                      Found in dpc-admin/app/assets/javascripts/components/_accordions.js - About 30 mins to fix

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

                        var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
                        Severity: Major
                        Found in dpc-admin/app/assets/javascripts/components/_accordions.js and 1 other location - About 3 hrs to fix
                        dpc-admin/app/assets/javascripts/components/_accordions.js on lines 223..223

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

                        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

                        var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
                        Severity: Major
                        Found in dpc-admin/app/assets/javascripts/components/_accordions.js and 1 other location - About 3 hrs to fix
                        dpc-admin/app/assets/javascripts/components/_accordions.js on lines 767..767

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

                        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

                            remove: function removeBehavior(element) {
                              listeners.forEach(function (listener) {
                                element.removeEventListener(listener.type, listener.delegate, listener.options);
                              });
                            }
                        Severity: Major
                        Found in dpc-admin/app/assets/javascripts/components/_accordions.js and 1 other location - About 1 hr to fix
                        dpc-admin/app/assets/javascripts/components/_accordions.js on lines 439..443

                        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

                            add: function addBehavior(element) {
                              listeners.forEach(function (listener) {
                                element.addEventListener(listener.type, listener.delegate, listener.options);
                              });
                            },
                        Severity: Major
                        Found in dpc-admin/app/assets/javascripts/components/_accordions.js and 1 other location - About 1 hr to fix
                        dpc-admin/app/assets/javascripts/components/_accordions.js on lines 444..448

                        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

                        There are no issues that match your filters.

                        Category
                        Status