uktrade/directory-sso-profile

View on GitHub

Showing 24 of 388 total issues

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

    def clean(self):
        cleaned_data = super().clean()
        if 'company_number' in cleaned_data:
            data = helpers.get_companies_house_profile(cleaned_data['company_number'])
            if 'company_status' in data:
Severity: Minor
Found in enrolment/forms.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):
        try:
            if form.cleaned_data['action'] == form.SEND_REQUEST:
                helpers.collaboration_request_create(sso_session_id=self.request.user.session_id, role=user_roles.ADMIN)
            elif form.cleaned_data['action'] == form.SEND_REMINDER:
Severity: Minor
Found in profile/business_profile/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_context_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
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 - 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_form_initial has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
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 - 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