Showing 66 of 168 total issues
File forms.py
has 754 lines of code (exceeds 250 allowed). Consider refactoring. Open
from formation.combinable_base import CombinableFormSpec, FormSpecSelector
from formation.form_base import Form
from formation.display_form_base import DisplayForm
from formation import fields as F
from formation.validators import (
File fields.py
has 647 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django.utils import timezone
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.core.validators import (
EmailValidator, URLValidator, RegexValidator, MinValueValidator,
File field_types.py
has 384 lines of code (exceeds 250 allowed). Consider refactoring. Open
import re
import string
import phonenumbers
from phonenumbers.phonenumberutil import NumberParseException
from formation.field_base import Field
File admin_views.py
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django.shortcuts import redirect, get_object_or_404
from django.urls import reverse_lazy, reverse
from django.views.generic import View
from django.views.generic.base import TemplateView
from django.http import Http404, HttpResponse
File form_submission.py
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
import uuid
from urllib.parse import urljoin
from django.conf import settings
from django.db import models
from django.contrib.postgres.fields import JSONField
File pdf_form_display.py
has 304 lines of code (exceeds 250 allowed). Consider refactoring. Open
import io
import string
import collections
from django.conf import settings
FormSubmission
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class FormSubmission(models.Model):
text_search_fields = FORMSUBMISSION_TEXT_SEARCH_FIELDS
answer_fields = (
FORMSUBMISSION_TEXT_SEARCH_FIELDS +
File events_service.py
has 296 lines of code (exceeds 250 allowed). Consider refactoring. Open
import intake.services.applicants as ApplicantsService
import project.services.logging_service as LoggingService
from intake.services import status_notifications as SNService
from intake.tasks import log_to_mixpanel
from intake.serializers import (
BindParseValidate
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class BindParseValidate(Renderable):
"""Performs the essential tasks of any form or form field.
If given raw input data as a dict or MultiValueDict, it
will parse and validate the data, storing any parsed data
and any errors that arose.
Function buildChart2
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildChart2(data) {
var timeline = data.map(function (oneOrgsData) {
var weeklyRates = oneOrgsData.weekly_totals.map(function(week) {
week.date = moment(week.date).format('YYYY-MM-DD');
week.count = Number(week.count);
Function create_fake_applications
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def create_fake_applications(context, count, org_slug=None, status=None):
count = int(count)
if org_slug:
org = Organization.objects.get(slug=org_slug)
factories.FormSubmissionWithOrgsFactory.create_batch(
- 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 __call__
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def __call__(self, request):
if not is_a_monitoring_request(request):
visitor_id = request.session.get('visitor_id', None)
if not visitor_id:
visitor = Visitor(
- 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 incrementer
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
var incrementer = (function() {
var i = {
increment: function(input) {
var max = parseInt($(input).attr('max'));
var value = parseInt($(input).val());
Function email_csv
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def email_csv(request):
if not request.user.has_perm('clips.change_clip'):
return HttpResponseForbidden()
now = datetime.datetime.now()
now_str = now.strftime("%Y-%m-%d-%H-%M")
- 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 orgs_display_data
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def orgs_display_data(org_app_data_by_week, orgs, year_weeks):
"""
Generate a list of dictionaries of data suitable for our view to render
stats for each individual organization which receives applications. Each
dictionary includes metadata about the organization whose stats are being
- 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 find_duplicates
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def find_duplicates(search_space):
duplicate_sets = []
for pair in itertools.combinations(search_space, 2):
if are_duplicates(*pair):
pair_set = set(pair)
- 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 buildChart1
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildChart1(data){
var timeline = data.map(function (oneOrgsData) {
var weeklyRates = oneOrgsData.weekly_totals.map(function(week) {
week.date = moment(week.date).format('YYYY-MM-DD');
week.count = Number(week.count);
Function incrementer
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
var incrementer = (function() {
var i = {
increment: function(input) {
var max = parseInt($(input).attr('max'));
var value = parseInt($(input).val());
- 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 parse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def parse(self, raw_value):
"""CharFields check that input values are string types before
stripping them of leading and trailing whitespace
"""
value = self.empty_value
- 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 agency_event_logs
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def agency_event_logs(self, event_type):
'''assumes that self.logs and self.logs.user are prefetched'''
for log in self.logs.all():
if log.user and hasattr(log.user, 'profile'):
if log.user.profile.organization.is_receiving_agency:
- 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"