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
- 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 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]
- 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 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
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()
- 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 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
- 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 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(
- 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 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:
- 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 set_lesson_completed
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def set_lesson_completed(user, service_name, lesson_name, lesson, module):
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:
- 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 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']
- 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 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:
- 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 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'):
- 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"