rubyforgood/casa

View on GitHub

Showing 93 of 93 total issues

Function formatTimestampsAsBubbleChartData has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function formatTimestampsAsBubbleChartData (timestamps) {
  const bubbleDataAsObject = {}

  for (const timestamp of timestamps) {
    const contactCreationTime = new Date(timestamp * 1000)
Severity: Minor
Found in app/javascript/src/display_app_metric.js - About 1 hr to fix

    Method raw_records has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def raw_records
        base_relation
          .select(
            <<-SQL
              users.*,
    Severity: Minor
    Found in app/datatables/volunteer_datatable.rb - About 1 hr to fix

      Function onCreate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      patchNoteFunctions.onCreate = function () {
        try {
          const patchNoteList = $('#patch-note-list')
          const newPatchNoteFormInputs = patchNoteFunctions.getPatchNoteFormInputs($('#new-patch-note'))
      
      
      Severity: Minor
      Found in app/javascript/src/all_casa_admin/patch_notes.js - About 1 hr to fix

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

              @volunteer.invite!(current_user)
              # call short io api here
              raw_token = @volunteer.raw_invitation_token
              invitation_url = Rails.application.routes.url_helpers.accept_user_invitation_url(invitation_token: raw_token, host: request.base_url)
              hash_of_short_urls = @volunteer.phone_number.blank? ? {0 => nil, 1 => nil} : handle_short_url([invitation_url, request.base_url + "/users/edit"])
        Severity: Major
        Found in app/controllers/volunteers_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/supervisors_controller.rb on lines 29..37

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

        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

              @supervisor.invite!(current_user)
              # call short io api here
              raw_token = @supervisor.raw_invitation_token
              invitation_url = Rails.application.routes.url_helpers.accept_user_invitation_url(invitation_token: raw_token, host: request.base_url)
              hash_of_short_urls = @supervisor.phone_number.blank? ? {0 => nil, 1 => nil} : handle_short_url([invitation_url, request.base_url + "/users/edit"])
        Severity: Major
        Found in app/controllers/supervisors_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/volunteers_controller.rb on lines 35..43

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

        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 createPatchNote has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        patchNoteFunctions.createPatchNote = function (patchNoteGroupId, patchNoteText, patchNoteTypeId) {
          // Input check
          TypeChecker.checkPositiveInteger(patchNoteGroupId, 'patchNoteGroupId')
          TypeChecker.checkPositiveInteger(patchNoteTypeId, 'patchNoteTypeId')
          TypeChecker.checkString(patchNoteText, 'patchNoteText')
        Severity: Minor
        Found in app/javascript/src/all_casa_admin/patch_notes.js - About 1 hr to fix

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

          patchNoteFunctions.addPatchNoteUI = function (patchNoteGroupId, patchNoteId, patchNoteList, patchNoteText, patchNoteTypeId) {
            TypeChecker.checkPositiveInteger(patchNoteGroupId, 'patchNoteGroupId')
            TypeChecker.checkPositiveInteger(patchNoteId, 'patchNoteId')
            TypeChecker.checkPositiveInteger(patchNoteTypeId, 'patchNoteTypeId')
            TypeChecker.checkNonEmptyJQueryObject(patchNoteList, 'patchNoteList')
          Severity: Minor
          Found in app/javascript/src/all_casa_admin/patch_notes.js - About 1 hr to fix

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

            function formatTimestampsAsBubbleChartData (timestamps) {
              const bubbleDataAsObject = {}
            
              for (const timestamp of timestamps) {
                const contactCreationTime = new Date(timestamp * 1000)
            Severity: Minor
            Found in app/javascript/src/display_app_metric.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

            Method import_cases has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def import_cases
                import do |row|
                  casa_case_params = row.to_hash.slice(:case_number, :birth_month_year_youth).compact
            
                  unless casa_case_params.key?(:case_number)
            Severity: Minor
            Found in app/lib/importers/case_importer.rb - 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

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

                      setTimeout(() => {
                        expect(savedToast.attr('style')).toEqual(expect.not.stringContaining('display: none'))
                        done()
                      }, 4000)
            Severity: Minor
            Found in app/javascript/__tests__/notifier.test.js and 1 other location - About 55 mins to fix
            app/javascript/__tests__/notifier.test.js on lines 361..364

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

            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

                      setTimeout(() => {
                        expect(savedToast.attr('style')).toEqual(expect.not.stringContaining('display: none'))
                        done()
                      }, 2000)
            Severity: Minor
            Found in app/javascript/__tests__/notifier.test.js and 1 other location - About 55 mins to fix
            app/javascript/__tests__/notifier.test.js on lines 384..387

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

            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

            Method import_volunteers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def import_volunteers
                import do |row|
                  volunteer_params = row.to_hash.slice(:display_name, :email, :phone_number).compact
            
                  unless volunteer_params.key?(:email)
            Severity: Minor
            Found in app/lib/importers/volunteer_importer.rb - 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

            Method update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                authorize @case_contact
                params[:case_contact][:status] = step.to_s if !@case_contact.active? && params.key?(:case_contact)
                remove_unwanted_contact_types
                remove_nil_draft_ids
            Severity: Minor
            Found in app/controllers/case_contacts/form_controller.rb - 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

            Method process_casa_case_date has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def process_casa_case_date(cc, import_date, case_number, already_has_nonmatching_date, no_edit_made, updated_casa_cases, case_not_found)
            Severity: Major
            Found in scripts/import_casa_case_date_of_birth.rb - About 50 mins to fix

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

                    {
                      name: 'has_transition_aged_youth_cases',
                      render: (data, type, row, meta) => {
                        return `
                        <span class="mobile-label">Assigned to Transitioned Aged Youth</span>
              Severity: Minor
              Found in app/javascript/src/dashboard.js and 1 other location - About 50 mins to fix
              app/javascript/src/dashboard.js on lines 179..188

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

              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

                    {
                      name: 'active',
                      render: (data, type, row, meta) => {
                        return `
                          <span class="mobile-label">Status</span>
              Severity: Minor
              Found in app/javascript/src/dashboard.js and 1 other location - About 50 mins to fix
              app/javascript/src/dashboard.js on lines 189..197

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

              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 4 locations. Consider refactoring.
              Open

                  beforeEach(() => {
                    $(() => {
                      checkboxContainer = $('.contact-medium.form-group')
                      component = new NonDrivingContactMediumWarning($('.contact-medium.form-group input:not([type=hidden]), #case_contact_miles_driven'), notifier)
                    })
              Severity: Major
              Found in app/javascript/__tests__/validated_form.test.js and 3 other locations - About 50 mins to fix
              app/javascript/__tests__/validated_form.test.js on lines 90..95
              app/javascript/__tests__/validated_form.test.js on lines 194..199
              app/javascript/__tests__/validated_form.test.js on lines 244..249

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

              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

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

                  beforeEach(() => {
                    $(() => {
                      component = new NonDrivingContactMediumWarning($('.contact-medium.form-group input:not([type=hidden]), #case_contact_miles_driven'), notifier)
                      notifierElement = $('#notifications')
                    })
              Severity: Minor
              Found in app/javascript/__tests__/validated_form.test.js and 1 other location - About 50 mins to fix
              app/javascript/__tests__/validated_form.test.js on lines 529..534

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

              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 4 locations. Consider refactoring.
              Open

                  beforeEach(() => {
                    $(() => {
                      notifierElement = $('#notifications')
                      rangedDatePicker = new RangedDatePicker($('input'), notifier)
                    })
              Severity: Major
              Found in app/javascript/__tests__/validated_form.test.js and 3 other locations - About 50 mins to fix
              app/javascript/__tests__/validated_form.test.js on lines 90..95
              app/javascript/__tests__/validated_form.test.js on lines 244..249
              app/javascript/__tests__/validated_form.test.js on lines 429..434

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

              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 4 locations. Consider refactoring.
              Open

                  beforeEach(() => {
                    $(() => {
                      datePickerElement = $('input')
                      rangedDatePicker = new RangedDatePicker($('input'), notifier)
                    })
              Severity: Major
              Found in app/javascript/__tests__/validated_form.test.js and 3 other locations - About 50 mins to fix
              app/javascript/__tests__/validated_form.test.js on lines 194..199
              app/javascript/__tests__/validated_form.test.js on lines 244..249
              app/javascript/__tests__/validated_form.test.js on lines 429..434

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

              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

              Severity
              Category
              Status
              Source
              Language