uktrade/directory-sso-profile

View on GitHub

Showing 388 of 388 total issues

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

from urllib.parse import urlparse

from directory_constants import urls, user_roles
from directory_forms_api_client.helpers import FormSessionMixin
from django.contrib import messages
Severity: Major
Found in enrolment/views.py - About 1 day to fix

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

    from profile.business_profile import forms, helpers
    
    import sentry_sdk
    from directory_api_client.client import api_client
    from directory_constants import urls, user_roles
    Severity: Minor
    Found in profile/business_profile/views.py - About 7 hrs to fix

      File forms.py has 418 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from profile.business_profile import constants, validators
      
      import directory_validators.file
      import directory_validators.string
      import directory_validators.url
      Severity: Minor
      Found in profile/business_profile/forms.py - About 6 hrs to fix

        Function productsServicesTypeahead has 97 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        dit.components.productsServicesTypeahead = (function() {
          function ProductsServicesTypeahead(options) {
        
            var multiselectElement = options.multiselectElement;
            var choices = options.choices;
        Severity: Major
        Found in core/static/js/products-services.js - About 3 hrs to fix

          Function ProductsServicesTypeahead has 92 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function ProductsServicesTypeahead(options) {
          
              var multiselectElement = options.multiselectElement;
              var choices = options.choices;
              var selectedValuesElement = options.selectedValuesElement;
          Severity: Major
          Found in core/static/js/products-services.js - About 3 hrs to fix

            Function expertise has 84 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            dit.components.expertise = (function() {
              function ExpertiseTypeahead(options) {
            
                var multiselectElement = options.multiselectElement;
                var selectedValuesElement = options.selectedValuesElement;
            Severity: Major
            Found in core/static/js/expertise.js - About 3 hrs to fix

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

                function ExpertiseTypeahead(options) {
              
                  var multiselectElement = options.multiselectElement;
                  var selectedValuesElement = options.selectedValuesElement;
                  var noResultsLabel = options.noResultsLabel;
              Severity: Major
              Found in core/static/js/expertise.js - About 3 hrs to fix

                File urls.py has 272 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import profile.business_profile.views
                import profile.exops.views
                import profile.personal_profile.views
                import profile.soo.views
                
                
                Severity: Minor
                Found in conf/urls.py - About 2 hrs to fix

                  Cyclomatic complexity is too high in method __init__. (9)
                  Open

                      def __init__(self, initial, is_enrolled=False, *args, **kwargs):
                          super().__init__(initial=initial, *args, **kwargs)
                          for field_name in ['sic', 'address']:
                              if initial.get(field_name):
                                  character_count = len(initial[field_name])
                  Severity: Minor
                  Found in enrolment/forms.py by radon

                  Cyclomatic Complexity

                  Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                  Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                  Construct Effect on CC Reasoning
                  if +1 An if statement is a single decision.
                  elif +1 The elif statement adds another decision.
                  else +0 The else statement does not cause a new decision. The decision is at the if.
                  for +1 There is a decision at the start of the loop.
                  while +1 There is a decision at the while statement.
                  except +1 Each except branch adds a new conditional path of execution.
                  finally +0 The finally block is unconditionally executed.
                  with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                  assert +1 The assert statement internally roughly equals a conditional statement.
                  Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                  Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Function expertise has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                  dit.components.expertise = (function() {
                    function ExpertiseTypeahead(options) {
                  
                      var multiselectElement = options.multiselectElement;
                      var selectedValuesElement = options.selectedValuesElement;
                  Severity: Minor
                  Found in core/static/js/expertise.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 productsServicesTypeahead has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                  dit.components.productsServicesTypeahead = (function() {
                    function ProductsServicesTypeahead(options) {
                  
                      var multiselectElement = options.multiselectElement;
                      var choices = options.choices;
                  Severity: Minor
                  Found in core/static/js/products-services.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

                  File mixins.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import abc
                  from urllib.parse import unquote
                  
                  from directory_sso_api_client import sso_api_client
                  from django.contrib import messages
                  Severity: Minor
                  Found in enrolment/mixins.py - About 2 hrs to fix

                    Cyclomatic complexity is too high in method get. (7)
                    Open

                        def get(self, *args, **kwargs):
                            key = self.request.GET.get('key')
                            if key:
                                data = helpers.retrieve_preverified_company(key)
                                if data:
                    Severity: Minor
                    Found in enrolment/views.py by radon

                    Cyclomatic Complexity

                    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                    Construct Effect on CC Reasoning
                    if +1 An if statement is a single decision.
                    elif +1 The elif statement adds another decision.
                    else +0 The else statement does not cause a new decision. The decision is at the if.
                    for +1 There is a decision at the start of the loop.
                    while +1 There is a decision at the while statement.
                    except +1 Each except branch adds a new conditional path of execution.
                    finally +0 The finally block is unconditionally executed.
                    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                    assert +1 The assert statement internally roughly equals a conditional statement.
                    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                    Source: http://radon.readthedocs.org/en/latest/intro.html

                    Cyclomatic complexity is too high in method validate_code. (7)
                    Open

                        def validate_code(self, form, response):
                            try:
                                upstream_response = helpers.confirm_verification_code(
                                    email=form.cleaned_data['email'], verification_code=form.cleaned_data['code']
                                )
                    Severity: Minor
                    Found in enrolment/mixins.py by radon

                    Cyclomatic Complexity

                    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                    Construct Effect on CC Reasoning
                    if +1 An if statement is a single decision.
                    elif +1 The elif statement adds another decision.
                    else +0 The else statement does not cause a new decision. The decision is at the if.
                    for +1 There is a decision at the start of the loop.
                    while +1 There is a decision at the while statement.
                    except +1 Each except branch adds a new conditional path of execution.
                    finally +0 The finally block is unconditionally executed.
                    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                    assert +1 The assert statement internally roughly equals a conditional statement.
                    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                    Source: http://radon.readthedocs.org/en/latest/intro.html

                    Function cookie has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                    GOVUK.cookie = (new function() {
                    
                      /* Set a cookie.
                       * @name (String) Name of cookie
                       * @value (String) Value to store
                    Severity: Minor
                    Found in profile/static/javascripts/index.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

                    Cyclomatic complexity is too high in method get_form_initial. (6)
                    Open

                        def get_form_initial(self, step):
                            form_initial = super().get_form_initial(step)
                            if step == constants.ADDRESS_SEARCH:
                                company = self.get_cleaned_data_for_step(constants.COMPANY_SEARCH) or {}
                                form_initial['company_name'] = company.get('company_name')
                    Severity: Minor
                    Found in enrolment/views.py by radon

                    Cyclomatic Complexity

                    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                    Construct Effect on CC Reasoning
                    if +1 An if statement is a single decision.
                    elif +1 The elif statement adds another decision.
                    else +0 The else statement does not cause a new decision. The decision is at the if.
                    for +1 There is a decision at the start of the loop.
                    while +1 There is a decision at the while statement.
                    except +1 Each except branch adds a new conditional path of execution.
                    finally +0 The finally block is unconditionally executed.
                    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                    assert +1 The assert statement internally roughly equals a conditional statement.
                    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                    Source: http://radon.readthedocs.org/en/latest/intro.html

                    Cyclomatic complexity is too high in class BusinessTypeRoutingView. (6)
                    Open

                    class BusinessTypeRoutingView(
                        mixins.RedirectAlreadyEnrolledMixin,
                        mixins.StepsListMixin,
                        mixins.WriteUserIntentMixin,
                        mixins.ReadUserIntentMixin,
                    Severity: Minor
                    Found in enrolment/views.py by radon

                    Cyclomatic Complexity

                    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                    Construct Effect on CC Reasoning
                    if +1 An if statement is a single decision.
                    elif +1 The elif statement adds another decision.
                    else +0 The else statement does not cause a new decision. The decision is at the if.
                    for +1 There is a decision at the start of the loop.
                    while +1 There is a decision at the while statement.
                    except +1 Each except branch adds a new conditional path of execution.
                    finally +0 The finally block is unconditionally executed.
                    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                    assert +1 The assert statement internally roughly equals a conditional statement.
                    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                    Source: http://radon.readthedocs.org/en/latest/intro.html

                    Cyclomatic complexity is too high in method form_valid. (6)
                    Open

                        def form_valid(self, form):
                            choice = form.cleaned_data['choice']
                            if choice == constants.COMPANIES_HOUSE_COMPANY:
                                url = URL_COMPANIES_HOUSE_ENROLMENT
                            elif choice == constants.NON_COMPANIES_HOUSE_COMPANY:
                    Severity: Minor
                    Found in enrolment/views.py by radon

                    Cyclomatic Complexity

                    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                    Construct Effect on CC Reasoning
                    if +1 An if statement is a single decision.
                    elif +1 The elif statement adds another decision.
                    else +0 The else statement does not cause a new decision. The decision is at the if.
                    for +1 There is a decision at the start of the loop.
                    while +1 There is a decision at the while statement.
                    except +1 Each except branch adds a new conditional path of execution.
                    finally +0 The finally block is unconditionally executed.
                    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                    assert +1 The assert statement internally roughly equals a conditional statement.
                    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                    Source: http://radon.readthedocs.org/en/latest/intro.html

                    Cyclomatic complexity is too high in method get_context_data. (6)
                    Open

                        def get_context_data(self, *args, **kwargs):
                            context = super().get_context_data(*args, **kwargs)
                            contact_us_url = urls.domestic.CONTACT_US / 'domestic'
                            if self.steps.current == constants.COMPANY_SEARCH:
                                context['contact_us_url'] = contact_us_url
                    Severity: Minor
                    Found in enrolment/views.py by radon

                    Cyclomatic Complexity

                    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                    Construct Effect on CC Reasoning
                    if +1 An if statement is a single decision.
                    elif +1 The elif statement adds another decision.
                    else +0 The else statement does not cause a new decision. The decision is at the if.
                    for +1 There is a decision at the start of the loop.
                    while +1 There is a decision at the while statement.
                    except +1 Each except branch adds a new conditional path of execution.
                    finally +0 The finally block is unconditionally executed.
                    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                    assert +1 The assert statement internally roughly equals a conditional statement.
                    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                    Source: http://radon.readthedocs.org/en/latest/intro.html

                    Function utm has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    GOVUK.utm = (new function() {
                      var utils = GOVUK.utils;
                    
                      this.set = function() {
                        // params = [utm_campaign|utm_content|utm_medium|utm_source\utm_term]
                    Severity: Minor
                    Found in profile/static/javascripts/index.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

                    Severity
                    Category
                    Status
                    Source
                    Language