uktrade/directory-components

View on GitHub

Showing 38 of 44 total issues

Function dismissableBanner has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

dit.components.dismissableBanner = (new function() {

  var BANNER_ID = 'information-banner';
  var BANNER_CLOSE_BUTTON_ID = 'dismiss-banner';

    Function render has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def render(self, context):
            html = self.nodelist.render(context)
            soup = BeautifulSoup(html, 'html.parser')
    
            selector = self.target.resolve(context)
    Severity: Minor
    Found in directory_components/templatetags/directory_components.py - 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 openMenu has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      self.openMenu = function() {
        $(self.MENU_BUTTON)
          .addClass("expanded")
          .attr("aria-expanded", "true");
        $(self.MOBILE_NAV)

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

          def __init__(self, *args, **kwargs):
              super().__init__(*args, **kwargs)
              for name, field in self.fields.items():
                  if isinstance(field, RadioNested):
                      nested_form = field.nested_form_class(*args, **kwargs)
      Severity: Minor
      Found in directory_components/forms/fields.py - 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 data has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      dit.data = (new function() {
      
        function Service(url, configuration) {
          var service = this;
          var config = $.extend({

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

            def handle(self, *args, **options):
                client = hvac.Client(url=f"https://{options['domain']}", token=options['token'])
                assert client.is_authenticated()
        
                for path in helpers.list_vault_paths(client=client, root=options['root']):
        Severity: Minor
        Found in directory_components/janitor/management/commands/vault_update.py - About 55 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 responsive has a Cognitive Complexity of 9 (exceeds 5 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: Minor
        Found in directory_components/static/directory_components/js/dit.responsive.js - About 55 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 resolve_setting_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def resolve_setting_name(name, settings_keys):
            resolved_name = None
            match = next((item for item in settings_keys if item == name), None)
        
            # prevent matching SECRET_KEY to LIBRARY_SECRET_KEY
        Severity: Minor
        Found in directory_components/janitor/management/commands/helpers.py - About 55 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 create_option has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def create_option(
        Severity: Major
        Found in directory_components/forms/widgets.py - About 50 mins to fix

          Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, nodelist,
          Severity: Major
          Found in directory_components/templatetags/directory_components.py - About 50 mins to fix

            Function CookiesModal has a Cognitive Complexity of 8 (exceeds 5 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 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

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

                def create_option(
                        self, name, value, label, selected, index,
                        subindex=None, attrs=None):
                    """Patch to use nicer ids."""
                    index = str(index) if subindex is None else "%s%s%s" % (
            Severity: Minor
            Found in directory_components/forms/widgets.py - 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

            Function formEvent has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    function formEvent(action, type, element, value, data) {
            Severity: Minor
            Found in directory_components/static/directory_components/js/dit.tagging.js - About 35 mins to fix

              Function linkEvent has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      function linkEvent(action, type, element, value, destination) {
              Severity: Minor
              Found in directory_components/static/directory_components/js/dit.tagging.js - About 35 mins to fix

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

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

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

                    def report_redundant_settings(self):
                        # false positives: if powered by env var but the default value that is the same as django default
                        self.stdout.write(
                            self.style.MIGRATE_LABEL('Looking for redundant settings')
                        )
                Severity: Minor
                Found in directory_components/janitor/management/commands/settings_shake.py - 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 ga360_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                def ga360_data(parser, token):
                    nodelist = parser.parse(('end_ga360_data',))
                    parser.delete_first_token()
                
                    # the ga360_data tag expects arguments in the following format
                Severity: Minor
                Found in directory_components/templatetags/directory_components.py - 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 clean_secrets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def clean_secrets(secrets):
                    ignore_settings = getattr(
                        settings,
                        'DIRECTORY_COMPONENTS_VAULT_IGNORE_SETTINGS_REGEX',
                        DEFAULT_UNSAFE_SETTINGS
                Severity: Minor
                Found in directory_components/janitor/management/commands/helpers.py - 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

                Severity
                Category
                Status
                Source
                Language