rubyforgood/casa

View on GitHub

Showing 40 of 93 total issues

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

      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

          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

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

            Method valid_phone_number has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def valid_phone_number(number)
                message = "must be 10 digits or 12 digits including country code (+1)"
            
                if number.nil? || number.empty?
                  return true, nil
            Severity: Minor
            Found in app/helpers/phone_number_helper.rb - About 45 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                authorize CaseAssignment
            
                if existing_case_assignment.present?
                  if existing_case_assignment.update(active: true)
            Severity: Minor
            Found in app/controllers/case_assignments_controller.rb - About 45 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 record_outdated? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def record_outdated?(record, new_data)
                new_data.each do |key, value|
                  # The parser keeps boolean values as strings
                  if record[key] != value || (value == ((record[key].in?([true, false]) && record[key]) ? "FALSE" : "TRUE"))
                    return true
            Severity: Minor
            Found in app/lib/importers/file_importer.rb - About 45 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

            Function addPatchNoteUI has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            patchNoteFunctions.addPatchNoteUI = function (patchNoteGroupId, patchNoteId, patchNoteList, patchNoteText, patchNoteTypeId) {
            Severity: Minor
            Found in app/javascript/src/all_casa_admin/patch_notes.js - About 35 mins to fix

              Method update_casa_case_dates_of_birth has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def update_casa_case_dates_of_birth(data, case_not_found, already_has_nonmatching_date, no_edit_made, updated_casa_cases)
              Severity: Minor
              Found in scripts/import_casa_case_date_of_birth.rb - About 35 mins to fix

                Method generate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def generate
                    authorize CaseCourtReport
                    casa_case = CasaCase.find_by(case_number: case_params[:case_number], casa_org: current_user.casa_org)
                
                    respond_to do |format|
                Severity: Minor
                Found in app/controllers/case_court_reports_controller.rb - About 25 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 apply_occurred_at_filter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def apply_occurred_at_filter(key, query)
                    return query if params[:occurred_at][key].empty?
                
                    query.where(
                      (key == :end) ? "? >= occurred_at" : "occurred_at >= ?",
                Severity: Minor
                Found in app/controllers/reimbursements_controller.rb - About 25 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 activate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def activate
                    authorize @volunteer
                    if @volunteer.activate
                      VolunteerMailer.account_setup(@volunteer).deliver
                
                
                Severity: Minor
                Found in app/controllers/volunteers_controller.rb - About 25 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 a Cognitive Complexity of 6 (exceeds 5 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)
                  if cc&.birth_month_year_youth
                    if !dates_match(cc, d2)
                      already_has_nonmatching_date << {case_number: case_number, prev_date: cc.birth_month_year_youth, import_date: d2}
                    else
                Severity: Minor
                Found in scripts/import_casa_case_date_of_birth.rb - About 25 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 perform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def perform
                    CSV.generate(headers: true) do |csv|
                      csv << full_data.keys.map(&:to_s).map(&:titleize)
                      if casa_cases.present?
                        casa_cases.decorate.each do |casa_case|
                Severity: Minor
                Found in app/services/missing_data_export_csv_service.rb - About 25 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 validate_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def validate_file(file, import_type)
                    # Validate that file is attached
                    if file.blank?
                      return {type: :error, message: ERR_FILE_NOT_ATTACHED}
                    end
                Severity: Minor
                Found in app/controllers/imports_controller.rb - About 25 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

                Severity
                Category
                Status
                Source
                Language