uktrade/directory-components

View on GitHub

Showing 38 of 44 total issues

Function header has 212 lines of code (exceeds 25 allowed). Consider refactoring.
Open

dit.components.header = new (function() {
  var self = this;

  self.MENU_BUTTON = "#mobile-menu-button";
  self.MOBILE_NAV = "#great-header-mobile-nav";

    Function lookup has 199 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    dit.components.lookup = (new function() {
    
      /* Performs a data lookup and displays multiple choice results
       * to populate the input value with user choice.
       *

      Function base has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
      Open

      dit.tagging.base = new function() {
          this.init = function(debug_mode) {
              $(document).ready(function() {
                  addTaggingForLinks();
                  addTaggingForVideos();
      Severity: Minor
      Found in directory_components/static/directory_components/js/dit.tagging.js - About 7 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 header has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

      dit.components.header = new (function() {
        var self = this;
      
        self.MENU_BUTTON = "#mobile-menu-button";
        self.MOBILE_NAV = "#great-header-mobile-nav";

      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 base has 147 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      dit.tagging.base = new function() {
          this.init = function(debug_mode) {
              $(document).ready(function() {
                  addTaggingForLinks();
                  addTaggingForVideos();
      Severity: Major
      Found in directory_components/static/directory_components/js/dit.tagging.js - About 5 hrs to fix

        Function cookieNotice has 147 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        dit.components.cookieNotice = function() {
          var COOKIE_NOTICE_ID = 'header-cookie-notice';
          var COOKIE_CLOSE_BUTTON_ID = 'dismiss-cookie-notice';
          var COOKIE_DOMAIN = $('#privacyCookieDomain').attr('value');
          var cookiePreferencesName = 'cookie_preferences_set';

          Function init has 145 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              this.init = function(debug_mode) {
                  $(document).ready(function() {
                      addTaggingForLinks();
                      addTaggingForVideos();
                      addTaggingForForms();
          Severity: Major
          Found in directory_components/static/directory_components/js/dit.tagging.js - About 5 hrs to fix

            Function countrySelector has 130 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            dit.components.countrySelector = (new function() {
              var self = this;
            
              var BANNER = '#country-selector-dialog';
              var BANNER_ID = 'country-selector-dialog';

              File views.py has 377 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import ast
              import re
              import lorem
              
              from unittest.mock import Mock
              Severity: Minor
              Found in demo/views.py - About 5 hrs to fix

                Function SelectiveLookup has 99 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function SelectiveLookup($input, service, options) {
                    var instance = this;
                    var popupId = dit.utils.uniqueString();
                
                    // Configure options.

                  File directory_components.py has 320 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  from bs4 import BeautifulSoup
                  import re
                  
                  from collections import namedtuple
                  
                  
                  Severity: Minor
                  Found in directory_components/templatetags/directory_components.py - About 3 hrs to fix

                    Function multiselectAutocomplete has 85 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    dit.components.multiselectAutocomplete = (function() {
                      function MultiSelectAutocomplete(options) {
                    
                        var selectInputElement = options.selectInputElement;
                        var autocompleteId = selectInputElement.id + '_autocomplete';

                      Function MultiSelectAutocomplete has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function MultiSelectAutocomplete(options) {
                      
                          var selectInputElement = options.selectInputElement;
                          var autocompleteId = selectInputElement.id + '_autocomplete';
                      
                      

                        Function responsive has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        dit.responsive = dit.responsive || (new function () {
                        
                          // Constants
                          var RESET_EVENT = "dit:responsive:reset";
                          var RESPONSIVE_ELEMENT_ID = "dit-responsive-size";
                        Severity: Major
                        Found in directory_components/static/directory_components/js/dit.responsive.js - About 3 hrs to fix

                          Function cookieNotice has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                          Open

                          dit.components.cookieNotice = function() {
                            var COOKIE_NOTICE_ID = 'header-cookie-notice';
                            var COOKIE_CLOSE_BUTTON_ID = 'dismiss-cookie-notice';
                            var COOKIE_DOMAIN = $('#privacyCookieDomain').attr('value');
                            var cookiePreferencesName = 'cookie_preferences_set';

                          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 code has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def code(parser, token):
                              # making the node verbatim
                              parameters = token.split_contents()
                              lang = parameters[1]
                              try:
                          Severity: Minor
                          Found in demo/templatetags/demo_tags.py - 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 multiselectAutocomplete has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                          Open

                          dit.components.multiselectAutocomplete = (function() {
                            function MultiSelectAutocomplete(options) {
                          
                              var selectInputElement = options.selectInputElement;
                              var autocompleteId = selectInputElement.id + '_autocomplete';

                          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 lookup has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                          dit.components.lookup = (new function() {
                          
                            /* Performs a data lookup and displays multiple choice results
                             * to populate the input value with user choice.
                             *

                          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 CookiesModal has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function CookiesModal(props) {
                            let firstLink;
                            const [isOpen, setIsOpen] = React.useState(props.isOpen)
                            const focusTrap = React.useRef(false);
                          
                          
                          Severity: Minor
                          Found in react-components/src/CookiesModal.jsx - About 1 hr to fix

                            Function languageSelectorDropdown has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            dit.components.languageSelectorDropdown = (new function() {
                              var self = this;
                            
                              var LANGUAGE_SELECT = '#great-header-language-select';
                              var LANGUAGE_SUBMIT = '#great-header-language-submit';
                              Severity
                              Category
                              Status
                              Source
                              Language