codeforamerica/intake

View on GitHub

Showing 146 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          fields = {
              F.ContactPreferences,
              F.FirstName,
              F.MiddleName,
              F.LastName,
      Severity: Major
      Found in formation/forms.py and 1 other location - About 6 hrs to fix
      formation/forms.py on lines 174..208

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 108.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          fields = {
              F.ContactPreferences,
              F.FirstName,
              F.MiddleName,
              F.LastName,
      Severity: Major
      Found in formation/forms.py and 1 other location - About 6 hrs to fix
      formation/forms.py on lines 374..408

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 108.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

            fields = {
                F.ContactPreferences,
                F.FirstName,
                F.MiddleName,
                F.LastName,
        Severity: Major
        Found in formation/forms.py and 2 other locations - About 3 hrs to fix
        formation/forms.py on lines 292..314
        formation/forms.py on lines 680..702

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 72.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

            required_fields = {
                F.ContactPreferences,
                F.FirstName,
                F.LastName,
                F.PhoneNumberField,
        Severity: Major
        Found in formation/forms.py and 2 other locations - About 3 hrs to fix
        formation/forms.py on lines 124..146
        formation/forms.py on lines 292..314

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 72.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

            fields = {
                F.ContactPreferences,
                F.FirstName,
                F.MiddleName,
                F.LastName,
        Severity: Major
        Found in formation/forms.py and 2 other locations - About 3 hrs to fix
        formation/forms.py on lines 124..146
        formation/forms.py on lines 680..702

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 72.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

                Cyclomatic complexity is too high in function update_tags_for_submission. (14)
                Open

                def update_tags_for_submission(user_id, submission_id, tags_input_string):
                    """Updates the set of tags tied to a submission.
                
                        Returns the updated set of tags tag names for the submission
                    """
                Severity: Minor
                Found in intake/services/tags.py by radon

                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.

                Source: http://radon.readthedocs.org/en/latest/intro.html

                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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  @when('the "{input_name}" text input is set to "{value}"')
                  def type_in_text_input(context, input_name, value):
                      selector = "input[name='%s'][type='text']" % (
                          input_name,
                      )
                  Severity: Major
                  Found in features/steps/form_input_steps.py and 1 other location - About 2 hrs to fix
                  features/steps/form_input_steps.py on lines 48..55

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 56.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  @when('the "{input_name}" text area is set to "{value}"')
                  def type_in_textarea(context, input_name, value):
                      selector = "textarea[name='%s']" % (
                          input_name,
                      )
                  Severity: Major
                  Found in features/steps/form_input_steps.py and 1 other location - About 2 hrs to fix
                  features/steps/form_input_steps.py on lines 38..45

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 56.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  @then('"{element_class}" should say "{text}"')
                  def test_class_element_contains_text(context, element_class, text):
                      element = context.browser.find_element_by_class_name(element_class)
                      context.test.assertTrue(
                          (text in element.text),
                  Severity: Major
                  Found in features/steps/web_loads_and_contains_steps.py and 1 other location - About 2 hrs to fix
                  features/steps/web_loads_and_contains_steps.py on lines 107..112

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 56.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  @then('the "{css_selector}" element should say "{text}"')
                  def test_css_selected_element_contains(context, css_selector, text):
                      element = context.browser.find_element_by_css_selector(css_selector)
                      context.test.assertTrue(
                          (text in element.text),
                  Severity: Major
                  Found in features/steps/web_loads_and_contains_steps.py and 1 other location - About 2 hrs to fix
                  features/steps/web_loads_and_contains_steps.py on lines 79..84

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 56.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Cyclomatic complexity is too high in function email_csv. (10)
                  Open

                  @login_required
                  def email_csv(request):
                      if not request.user.has_perm('clips.change_clip'):
                          return HttpResponseForbidden()
                      now = datetime.datetime.now()
                  Severity: Minor
                  Found in email_csv/views.py by radon

                  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.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Cyclomatic complexity is too high in class Command. (9)
                  Open

                  class Command(BaseCommand):
                      help = str(
                          "Finds all duplicate submissions and saves them as "
                          "DuplicateSubmissionSet objects")
                  
                  

                  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.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Severity
                  Category
                  Status
                  Source
                  Language