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
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
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
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;
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;
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;
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;
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
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])
- Read upRead up
- Exclude checks
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. |
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;
- Read upRead up
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;
- Read upRead up
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
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:
- Read upRead up
- Exclude checks
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. |
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']
)
- Read upRead up
- Exclude checks
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. |
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
- Read upRead up
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')
- Read upRead up
- Exclude checks
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. |
Cyclomatic complexity is too high in class BusinessTypeRoutingView. (6) Open
class BusinessTypeRoutingView(
mixins.RedirectAlreadyEnrolledMixin,
mixins.StepsListMixin,
mixins.WriteUserIntentMixin,
mixins.ReadUserIntentMixin,
- Read upRead up
- Exclude checks
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. |
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:
- Read upRead up
- Exclude checks
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. |
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
- Read upRead up
- Exclude checks
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. |
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]
- Read upRead up
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"