rubyforgood/casa

View on GitHub

Showing 93 of 93 total issues

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

      $('.transition-youth-options').find('input[type="checkbox"]').each(function () {
        if ($(this).is(':checked')) {
          assignedToTransitionYouthArray.push($(this).data('value'))
        }
      })
Severity: Major
Found in app/javascript/src/dashboard.js and 4 other locations - About 1 hr to fix
app/javascript/src/dashboard.js on lines 35..39
app/javascript/src/dashboard.js on lines 41..45
app/javascript/src/dashboard.js on lines 47..51
app/javascript/src/dashboard.js on lines 59..63

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

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

      $('.more-than-one-volunteer-options').find('input[type="checkbox"]').each(function () {
        if ($(this).is(':checked')) {
          assignedToMoreThanOneVolunteerArray.push($(this).data('value'))
        }
      })
Severity: Major
Found in app/javascript/src/dashboard.js and 4 other locations - About 1 hr to fix
app/javascript/src/dashboard.js on lines 35..39
app/javascript/src/dashboard.js on lines 41..45
app/javascript/src/dashboard.js on lines 53..57
app/javascript/src/dashboard.js on lines 59..63

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

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

      $('.assigned-to-volunteer-options').find('input[type="checkbox"]').each(function () {
        if ($(this).is(':checked')) {
          assignedToVolunteerArray.push($(this).data('value'))
        }
      })
Severity: Major
Found in app/javascript/src/dashboard.js and 4 other locations - About 1 hr to fix
app/javascript/src/dashboard.js on lines 35..39
app/javascript/src/dashboard.js on lines 47..51
app/javascript/src/dashboard.js on lines 53..57
app/javascript/src/dashboard.js on lines 59..63

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

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

  def save
    authorize CasaCase, :save_emancipation?
    params.permit(:casa_case_id, :check_item_action)

    begin
Severity: Minor
Found in app/controllers/emancipations_controller.rb - About 1 hr to fix

    Function onSavePatchNote has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    patchNoteFunctions.onSavePatchNote = function () {
      const patchNoteForm = $(this).parents('.card-body')
      const patchNoteFormInputs = patchNoteFunctions.getPatchNoteFormInputs(patchNoteForm)
    
      if ($(this).parent().siblings('textarea').val() === '') {
    Severity: Minor
    Found in app/javascript/src/all_casa_admin/patch_notes.js - About 1 hr to fix

      Method populate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.populate
          CaseContact.find_each do |case_contact|
            # Get rid of drafts
            unless case_contact.casa_case
              case_contact.destroy
      Severity: Minor
      Found in lib/tasks/data_post_processors/case_contact_populator.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

          } else {
            this.submitButtonTarget.disabled = false
            this.submitButtonTarget.classList.remove(this.disabledClass)
            this.submitButtonTarget.classList.add(...this.enabledClasses)
          }
      Severity: Major
      Found in app/javascript/controllers/disable_form_controller.js and 1 other location - About 1 hr to fix
      app/javascript/controllers/disable_form_controller.js on lines 19..23

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

      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

          if (invalid) {
            this.submitButtonTarget.disabled = true
            this.submitButtonTarget.classList.add(this.disabledClass)
            this.submitButtonTarget.classList.remove(...this.enabledClasses)
          } else {
      Severity: Major
      Found in app/javascript/controllers/disable_form_controller.js and 1 other location - About 1 hr to fix
      app/javascript/controllers/disable_form_controller.js on lines 23..27

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

      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 deactivate
          authorize @casa_admin
          if @casa_admin.deactivate
            CasaAdminMailer.deactivation(@casa_admin).deliver
      
      
      Severity: Major
      Found in app/controllers/casa_admins_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/casa_admins_controller.rb on lines 68..90

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

      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 activate
          authorize @casa_admin
      
          if @casa_admin.activate
            CasaAdminMailer.account_setup(@casa_admin).deliver
      Severity: Major
      Found in app/controllers/casa_admins_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/casa_admins_controller.rb on lines 92..109

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

      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

              render: (data, type, row, meta) => {
                return row.supervisor.id
                  ? `
                  <span class="mobile-label">Supervisor</span>
                    <a href="${editSupervisorPath(row.supervisor.id)}">
      Severity: Major
      Found in app/javascript/src/dashboard.js and 1 other location - About 1 hr to fix
      app/javascript/src/dashboard.js on lines 216..225

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

      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

              render: (data, type, row, meta) => {
                return row.most_recent_attempt.case_id
                  ? `
                    <span class="mobile-label">Last Attempted Contact</span>
                    <a href="${casaCasePath(row.most_recent_attempt.case_id)}">
      Severity: Major
      Found in app/javascript/src/dashboard.js and 1 other location - About 1 hr to fix
      app/javascript/src/dashboard.js on lines 168..177

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

      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 reactivate
          authorize @casa_case, :update_case_status?
      
          if @casa_case.reactivate
            respond_to do |format|
      Severity: Major
      Found in app/controllers/casa_cases_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/casa_cases_controller.rb on lines 84..101

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

      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 deactivate
          authorize @casa_case, :update_case_status?
      
          if @casa_case.deactivate
            respond_to do |format|
      Severity: Major
      Found in app/controllers/casa_cases_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/casa_cases_controller.rb on lines 106..123

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

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

      function handleGenerateReport (e) {
        e.preventDefault()
      
        const formData = Object.fromEntries(new FormData(e.currentTarget.form))
      
      
      Severity: Minor
      Found in app/javascript/src/casa_case.js - About 1 hr to fix

        Method initialize has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize(form:, hour_value:, minute_value:)
            @form = form
        
            if hour_value.is_a?(String)
              begin
        Severity: Minor
        Found in app/components/form/hour_minute_duration_component.rb - About 1 hr to fix

          Function createMultiSelectWithOptionGroups has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            createMultiSelectWithOptionGroups () {
              const optionTemplate = this.optionTarget.innerHTML
              const itemTemplate = this.itemTarget.innerHTML
          
              /* eslint-disable no-new */
          Severity: Minor
          Found in app/javascript/controllers/multiple_select_controller.js - About 1 hr to fix

            Function render has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    render: (data, type, row, meta) => {
                      const noContactVolunteers = Number(row.no_attempt_for_two_weeks)
                      const transitionAgedCaseVolunteers = Number(row.transitions_volunteers)
                      const activeContactVolunteers = Number(row.volunteer_assignments) - noContactVolunteers
                      const activeContactElement = activeContactVolunteers
            Severity: Minor
            Found in app/javascript/src/dashboard.js - About 1 hr to fix

              Method import_supervisors has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

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

              Function savePatchNote has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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