Showing 74 of 1,128 total issues
File views.py
has 794 lines of code (exceeds 250 allowed). Consider refactoring. Open
import json
from django.apps import apps
from django.db.models import Sum
from django.shortcuts import get_object_or_404
Function handle
has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
genders = ['male', 'female']
population_data = []
for gender in genders:
- 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 handle
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
given_env = options.get("env", None)
env = 'stage' if given_env else 'prod'
# Company supplied 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
File settings.py
has 469 lines of code (exceeds 250 allowed). Consider refactoring. Open
import os
import directory_healthcheck.backends
import dj_database_url
import environ
File views.py
has 427 lines of code (exceeds 250 allowed). Consider refactoring. Open
import abc
from directory_constants import user_roles
from django.conf import settings
from django.db.models import BooleanField, Case, Count, Q, Value, When
File urls.py
has 382 lines of code (exceeds 250 allowed). Consider refactoring. Open
import directory_healthcheck.views
import django
from django.conf import settings
from django.conf.urls import include
from django.contrib import admin
File models.py
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import gettext as _
from core.helpers import TimeStampedModel
File helpers.py
has 362 lines of code (exceeds 250 allowed). Consider refactoring. Open
import csv
import itertools
import logging
import re
from collections import defaultdict
File forms.py
has 339 lines of code (exceeds 250 allowed). Consider refactoring. Open
import ast
import csv
import io
import json
import re
Function clean_csv_file
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def clean_csv_file(self):
self.created_companies = []
self.skipped_companies = []
csv_file = io.TextIOWrapper(self.cleaned_data['csv_file'].file, encoding='utf-8')
dialect = csv.Sniffer().sniff(csv_file.read(1024))
- 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 handle
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
empty_ep_counter = 0
not_empty_ep_counter = 0
no_product_and_country_no_data = 0
- 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 load_raw_files
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def load_raw_files(self, filenames):
# Loads a raw file as downloaded from comtrade on top of existing data in db
for filename in filenames:
self.stdout.write(self.style.SUCCESS(f'******** Loading: {filename}'))
- 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 serializers.py
has 313 lines of code (exceeds 250 allowed). Consider refactoring. Open
import directory_validators.string
from directory_constants import choices, user_roles
from django.conf import settings
from django.http import QueryDict
from django.utils.timezone import now
File search_filters.py
has 306 lines of code (exceeds 250 allowed). Consider refactoring. Open
from elasticsearch_dsl import analysis
companies_stopwords_filter = analysis.token_filter(
'companies_stopwords', type='stop', stopwords=['limited', 'ltd', 'plc', 'llp', 'lp', 'rc', 'partnership', 'ngo']
)
Function update
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def update(self, instance, validated_data):
# This will allow partial updating to json fields during a patch update. Json fields generally represent
# a export plan page. we only want to update the field being sent else by nature we would wipe all the
# other fields
for field_name in validated_data.keys():
- 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 stage_ids.py
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
stage_ids = {
'05210891': 9285,
'06469178': 2054,
'09611823': 3762,
'03303852': 2918,
Function handle
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
count = 0
for export_plan in models.CompanyExportPlan.objects.all():
updated = False
- 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 views.py
has 288 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
from datetime import datetime
import django_filters.rest_framework
from django.conf import settings
Function handle
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
key_mapping = {'CPI score': 'cpi_score', 'Rank': 'rank'}
with open('dataservices/resources/corruption_perception_index.csv', 'r', encoding='utf-8-sig') as f:
file_reader = csv.DictReader(f)
- 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_unique_exportplan_name
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_unique_exportplan_name(ep_dict):
numbers_used = set()
sso_id = ep_dict.get('sso_id')
products = ep_dict.get('export_commodity_codes')
commodity_name = products[0].get('commodity_name') if products else ''
- 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"