rubyforgood/casa

View on GitHub

Showing 93 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

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

              test('Throws appropriate errors when initialized with values other than a valid jQuery object', (done) => {
                $(() => {
                  try {
                    expect(() => {
                      // eslint-disable-next-line no-new
          Severity: Major
          Found in app/javascript/__tests__/validated_form.test.js and 1 other location - About 4 hrs to fix
          app/javascript/__tests__/validated_form.test.js on lines 47..65

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

          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

              test('Throws appropriate errors when initialized with values other than a valid jQuery object', (done) => {
                $(() => {
                  try {
                    expect(() => {
                      // eslint-disable-next-line no-new
          Severity: Major
          Found in app/javascript/__tests__/validated_form.test.js and 1 other location - About 4 hrs to fix
          app/javascript/__tests__/validated_form.test.js on lines 347..365

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

          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

              test('shows an error notification to the user', (done) => {
                $(() => {
                  try {
                    const errorText = 'Q~Au\\`FMET"["8.JKB_M'
          
          
          Severity: Major
          Found in app/javascript/__tests__/validated_form.test.js and 1 other location - About 3 hrs to fix
          app/javascript/__tests__/validated_form.test.js on lines 488..503

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

          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

              test('it shows the user a warning through the notifier', (done) => {
                $(() => {
                  try {
                    const warningText = 'Q~Au\\`FMET"["8.JKB_M'
          
          
          Severity: Major
          Found in app/javascript/__tests__/validated_form.test.js and 1 other location - About 3 hrs to fix
          app/javascript/__tests__/validated_form.test.js on lines 201..215

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

          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

          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

          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

            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

            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

            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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language