codeforamerica/intake

View on GitHub

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 (
Severity: Major
Found in formation/forms.py - About 1 day to fix

    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,
    Severity: Major
    Found in formation/fields.py - About 1 day to fix

      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
      Severity: Minor
      Found in formation/field_types.py - About 5 hrs to fix

        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
        Severity: Minor
        Found in intake/views/admin_views.py - About 3 hrs to fix

          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
          Severity: Minor
          Found in intake/models/form_submission.py - About 3 hrs to fix

            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
            Severity: Minor
            Found in printing/pdf_form_display.py - About 3 hrs to fix

              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 +
              Severity: Minor
              Found in intake/models/form_submission.py - About 3 hrs to fix

                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 (
                Severity: Minor
                Found in intake/services/events_service.py - About 3 hrs to fix

                  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.
                  Severity: Minor
                  Found in formation/base.py - About 2 hrs to fix

                    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);
                    Severity: Minor
                    Found in intake/static/intake/js/stats_entry.js - About 1 hr to fix

                      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(
                      Severity: Minor
                      Found in features/steps/applications_steps.py - About 1 hr 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 __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(
                      Severity: Minor
                      Found in intake/middleware.py - About 1 hr 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 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());
                      Severity: Minor
                      Found in intake/static/intake/js/application.js - About 1 hr to fix

                        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")
                        Severity: Minor
                        Found in email_csv/views.py - About 1 hr 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 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
                        Severity: Minor
                        Found in intake/services/statistics.py - About 1 hr 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 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)
                        Severity: Minor
                        Found in intake/services/submissions.py - About 1 hr 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 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);
                        Severity: Minor
                        Found in intake/static/intake/js/stats_entry.js - About 1 hr to fix

                          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());
                          Severity: Minor
                          Found in intake/static/intake/js/application.js - About 1 hr 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 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
                          Severity: Minor
                          Found in formation/field_types.py - About 1 hr 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 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:
                          Severity: Minor
                          Found in intake/models/form_submission.py - About 1 hr 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