rubyforgood/casa

View on GitHub

Showing 100 of 100 total issues

File notifier.test.js has 743 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-env jest */
import { escape } from 'lodash'

require('jest')
const { Notifier, Notification } = require('../src/notifier.js')
Severity: Major
Found in app/javascript/__tests__/notifier.test.js - About 1 day to fix

    File dashboard.js has 433 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* global alert */
    /* global $ */
    const { Notifier } = require('./notifier')
    let pageNotifier
    
    
    Severity: Minor
    Found in app/javascript/src/dashboard.js - About 6 hrs to fix

      File patch_notes.js has 352 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const { Notifier } = require('../notifier')
      const TypeChecker = require('../type_checker')
      const patchNotePath = window.location.pathname
      const patchNoteFormBeforeEditData = {}
      const patchNoteFunctions = {} // A hack to be able to alphabetize functions
      Severity: Minor
      Found in app/javascript/src/all_casa_admin/patch_notes.js - About 4 hrs to fix

        File validated_form.test.js has 327 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* eslint-env jest */
        require('jest')
        
        const { Notifier } = require('../src/notifier.js')
        const { NonDrivingContactMediumWarning } = require('../src/validated_form.js')
        Severity: Minor
        Found in app/javascript/__tests__/validated_form.test.js - About 3 hrs to fix

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

            return $.ajax({
              url: patchNotePath,
              type: 'POST',
              data: {
                note: patchNoteText,
          Severity: Major
          Found in app/javascript/src/all_casa_admin/patch_notes.js and 1 other location - About 3 hrs to fix
          app/javascript/src/all_casa_admin/patch_notes.js on lines 107..124

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

          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

            return $.ajax({
              url: `${patchNotePath}/${patchNoteId}`,
              type: 'DELETE',
              beforeSend: function () {
                pageNotifier.waitForAsyncOperation()
          Severity: Major
          Found in app/javascript/src/all_casa_admin/patch_notes.js and 1 other location - About 3 hrs to fix
          app/javascript/src/all_casa_admin/patch_notes.js on lines 71..93

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

          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

          Class ApplicationPolicy has 26 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class ApplicationPolicy
            class Scope
              attr_reader :user, :scope
          
              def initialize(user, scope)
          Severity: Minor
          Found in app/policies/application_policy.rb - About 3 hrs to fix

            Class CasaCaseDecorator has 24 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class CasaCaseDecorator < Draper::Decorator
              include ActionView::Helpers::DateHelper
            
              delegate_all
            
            
            Severity: Minor
            Found in app/decorators/casa_case_decorator.rb - About 2 hrs to fix

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

              const handleReadMore = (event) => {
                event.preventDefault()
              
                const wrapper = event.target.closest('.js-read-more-text-wrapper')
                wrapper.querySelector('.js-full-text').style.display = 'block'
              Severity: Major
              Found in app/javascript/src/read_more.js and 1 other location - About 2 hrs to fix
              app/javascript/src/read_more.js on lines 21..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 88.

              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

              const handleReadLess = (event) => {
                event.preventDefault()
              
                const wrapper = event.target.closest('.js-read-more-text-wrapper')
                wrapper.querySelector('.js-truncated-text').style.display = 'block'
              Severity: Major
              Found in app/javascript/src/read_more.js and 1 other location - About 2 hrs to fix
              app/javascript/src/read_more.js on lines 13..19

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

              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

              Class CaseContactDecorator has 22 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class CaseContactDecorator < Draper::Decorator
                delegate_all
              
                NOTES_CHARACTER_LIMIT = 100
              
              
              Severity: Minor
              Found in app/decorators/case_contact_decorator.rb - About 2 hrs to fix

                Class CaseContact has 21 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class CaseContact < ApplicationRecord
                  include ByOrganizationScope
                  acts_as_paranoid
                
                  attr_accessor :duration_hours
                Severity: Minor
                Found in app/models/case_contact.rb - About 2 hrs to fix

                  Method initialize has a Cognitive Complexity of 16 (exceeds 5 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 2 hrs 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 createChart has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function createChart (chartElement, dataset) {
                    const ctx = chartElement.getContext('2d')
                  
                    return new Chart(ctx, {
                      type: 'bubble',
                  Severity: Major
                  Found in app/javascript/src/display_app_metric.js - About 2 hrs to fix

                    Function addAndCreate has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      addAndCreate (e) {
                        this.add(e)
                        const items = this.element.querySelectorAll(this.wrapperSelectorValue)
                        const addedItem = items[items.length - 1]
                        // childIndex will be 0,1,... for items at page load, timestamps for items added to form.
                    Severity: Minor
                    Found in app/javascript/controllers/casa_nested_form_controller.js - About 1 hr to fix

                      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

                            $('.case-number-prefix-options').find('input[type="checkbox"]').each(function () {
                              if ($(this).is(':checked')) {
                                caseNumberPrefixArray.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 53..57

                      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

                            $('.status-options').find('input[type="checkbox"]').each(function () {
                              if ($(this).is(':checked')) {
                                statusArray.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 41..45
                      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

                      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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language