uktrade/directory-sso

View on GitHub

Showing 12 of 334 total issues

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 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 12 (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 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 static/javascripts/index.js - About 1 hr to fix

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

        def handle(self, *args, **options):
            queryset = User.inactive
    
            today = datetime.now()
    
    
    Severity: Minor
    Found in sso/management/commands/notify_users.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 send_mail has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def send_mail(self, template_prefix, email, context):
            # Don't send an email if the account doesn't exist
            if template_prefix == 'account/email/unknown_account':
                return None
    
    
    Severity: Minor
    Found in sso/adapters.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 is_valid_domain has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def is_valid_domain(domain):
        # NOTE: tldextract and urlparse both have their shortcomings so
        # using both for what they do good
        # add local domain suffix because it is non-standard
        extract_with_extra_suffix = tldextract.TLDExtract(
    Severity: Minor
    Found in core/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 inject_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def inject_data(user, user_data_name, items):
        data_object = UserData.objects.filter(user=user, name=user_data_name).first()
        data_object = data_object or UserData(user=user, name=user_data_name)
    
        if not data_object.data:
    Severity: Minor
    Found in sso/user/management/commands/move_ep_to_basket.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 set_lesson_completed has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def set_lesson_completed(user, service_name, lesson_name, lesson, module):
    Severity: Minor
    Found in sso/user/utils.py - About 35 mins to fix

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

          def process_view(self, request, view_func, view_args, view_kwarg):
              # Django admin users without permission will be displayed custom message to request access
              if request.user.is_authenticated:
                  if self.is_admin_name_space(request) or request.path_info.startswith('/admin/login'):
                      if not request.user.is_staff:
      Severity: Minor
      Found in core/middleware.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 get_social_account_image has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_social_account_image(account):
          if account.provider == 'linkedin_oauth2':
              for size_variant in account.extra_data.get('profilePicture', {}).get('displayImage~', {}).get('elements', {}):
                  for image in size_variant['identifiers']:
                      return image['identifier']
      Severity: Minor
      Found in sso/user/utils.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 form_valid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def form_valid(self, form):
              response = super().form_valid(form)
              if response.status_code == 302 and response.url == reverse("account_email_verification_sent"):
                  return response
              elif response.url == RESEND_VERIFICATION_URL:
      Severity: Minor
      Found in sso/user/views.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

      Function get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get(self, request):
              service = request.query_params.get('service')
              filter_dict = dict()
              for item in request.query_params:
                  if item not in ('user', 'service'):
      Severity: Minor
      Found in sso/user/views_api.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