rubyforgood/casa

View on GitHub

Showing 40 of 93 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 validated_form.test.js has 545 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-env jest */
    require('jest')
    
    const { Notifier } = require('../src/notifier.js')
    const { NonDrivingContactMediumWarning, RangedDatePicker } = require('../src/validated_form.js')
    Severity: Major
    Found in app/javascript/__tests__/validated_form.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

          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 23 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

              Class CaseContact has 23 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

                Class CaseContactDecorator has 21 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

                  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

                    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

                        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

                                  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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language