uktrade/directory-sso-profile

View on GitHub

Showing 24 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

                  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

                    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

                    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

                    Function cookie has 35 lines of code (exceeds 25 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

                      Function __init__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      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 - 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 utm has 28 lines of code (exceeds 25 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

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

                            def form_valid(self, form):
                                try:
                                    if form.cleaned_data['collaborator_email']:
                                        helpers.collaborator_invite_create(
                                            sso_session_id=self.request.user.session_id,
                        Severity: Minor
                        Found in profile/business_profile/views.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 get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        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 - 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 process_step has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def process_step(self, form):
                                if form.prefix == constants.USER_ACCOUNT:
                                    response = sso_api_client.user.create_user(
                                        email=form.cleaned_data['email'], password=form.cleaned_data['password']
                                    )
                        Severity: Minor
                        Found in enrolment/mixins.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 form_valid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        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 - 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

                        Severity
                        Category
                        Status
                        Source
                        Language