codeforamerica/intake

View on GitHub

Showing 146 of 168 total issues

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

Severity: Major
Found in intake/models/status_type.py and 1 other location - About 1 hr to fix
intake/models/next_step.py on lines 0..14

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 40.

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 = (SonomaCountyFormSpec.fields | {
        F.Aliases,
        F.CaseNumber,
        F.CurrentlyEmployed,
        F.MonthlyIncome,
Severity: Major
Found in formation/forms.py and 1 other location - About 1 hr to fix
formation/forms.py on lines 148..161

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 40.

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

Function initializeSearchWidget has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function initializeSearchWidget(inputSelector, postURL, resultsCallback, emptySearchCallback){
  var currentXHR = null;

  function handleResultsAndResetRequest(callback){
    return function(results){
Severity: Minor
Found in intake/static/intake/js/search_widget.js - About 1 hr to fix

    Function buildSearchFunction has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function buildSearchFunction(searchSpace){
      return function (searchTerm){
        searchTerm = searchTerm.trim();
        var termLength = searchTerm.length;
        var results = [];
    Severity: Minor
    Found in intake/static/intake/js/tag_search.js - About 1 hr to fix

      Function _fill has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _fill(self, pdf_path, output_path, option_check, answers):
              answer_fields = {'fields': []}
              # TODO: make this less nested
              for k, v in answers.items():
                  if k in option_check:
      Severity: Minor
      Found in intake/pdfparser.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 handle has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle(self, *args, **options):
              subs = models.FormSubmission.objects.filter(dob__isnull=True)
              migrated = 0
              errored = 0
              for sub in subs:
      Severity: Minor
      Found in intake/management/commands/migrate_dob.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 count_unreads_and_send_notifications_to_orgs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def count_unreads_and_send_notifications_to_orgs():
          orgs = get_orgs_that_might_need_a_bundle_email_today()
          errors = []
          for org in orgs:
              if org.slug != 'cfa':
      Severity: Minor
      Found in intake/services/bundles.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 handle_django_validation_error has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_django_validation_error(self, error):
              """Django's ValidationError can include lists of errors,
              dicts of errors or just have a simple error message.
              This method is responsible for pulling error messages out of
              Django ValidationError objects and selecting the right way to
      Severity: Minor
      Found in formation/base.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 followUpQuestion has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var followUpQuestion = (function() {
        var fUQ = {
          init: function() {
      
            // if any initial questions are already selected on page load, show the follow up
      Severity: Minor
      Found in intake/static/intake/js/application.js - About 1 hr to fix

        Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, *args, form=None, required=True, recommended=False,
        Severity: Major
        Found in formation/field_base.py - About 1 hr to fix

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

              def get_notification_channel(self, method):
                  if method == EMAIL:
                      return notifications.email_followup
                  elif method == SMS:
                      return notifications.sms_followup
          Severity: Major
          Found in intake/service_objects/applicant_notifications.py and 1 other location - About 1 hr to fix
          intake/service_objects/applicant_notifications.py on lines 130..134

          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 38.

          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

              def get_notification_channel(self, method):
                  if method == EMAIL:
                      return notifications.email_confirmation
                  elif method == SMS:
                      return notifications.sms_confirmation
          Severity: Major
          Found in intake/service_objects/applicant_notifications.py and 1 other location - About 1 hr to fix
          intake/service_objects/applicant_notifications.py on lines 92..96

          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 38.

          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

          Function link_with_any_duplicates has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def link_with_any_duplicates(submission, applicant_id):
              """Links submission with any duplicates from the same applicant
          
              If duplicates are found, returns the DuplicateSubmissionSet id
              If no duplicates are found, returns False
          Severity: Minor
          Found in intake/services/submissions.py - About 55 mins 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 dont_audit_fixture_loading has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def dont_audit_fixture_loading(
          Severity: Major
          Found in access_audit/helpers.py - About 50 mins to fix

            Function log_multiple has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def log_multiple(cls, event_type, submission_ids,
            Severity: Major
            Found in intake/models/application_log_entry.py - About 50 mins to fix

              Function drawStreamFractionsChart has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function drawStreamFractionsChart (chart, chartConfig, sizes, data, xScale, yScale) {
              Severity: Minor
              Found in intake/static/intake/js/org_charts.js - About 45 mins to fix

                Function checkboxSelector has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                var checkboxSelector = (function() {
                  var cs = {
                    init: function() {
                      $('.checkbox').each(function(index, button){
                        if($(this).find('input').is(':checked')) {
                Severity: Minor
                Found in intake/static/intake/js/application.js - About 45 mins 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 get_existing_model has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_existing_model(cls, data, lookup, qset):
                        for instance in qset:
                            is_object = True
                            for key in lookup:
                                if getattr(instance, key, None) != lookup[key]:
                Severity: Minor
                Found in project/migration_utils.py - About 45 mins 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 drawBarChart has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function drawBarChart (chart, chartConfig, sizes, data, xScale, yScale) {
                Severity: Minor
                Found in intake/static/intake/js/org_charts.js - About 45 mins to fix

                  Function drawLineChart has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function drawLineChart (chart, chartConfig, sizes, data, xScale, yScale) {
                  Severity: Minor
                  Found in intake/static/intake/js/org_charts.js - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language