rubyforgood/casa

View on GitHub

Showing 45 of 100 total issues

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

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

          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 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)
                    if number.nil? || number.empty?
                      return true, nil
                    end
                
                
                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

                    Function initializeMenuHighlight has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      initializeMenuHighlight () {
                        const linkHash = this.anchorLinkMap()
                    
                        const observer = new window.IntersectionObserver(entries => {
                          entries.forEach(entry => {
                    Severity: Minor
                    Found in app/javascript/controllers/sidebar_group_controller.js - About 35 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 set_active_banner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def set_active_banner
                        return nil unless request.format.html?
                        return nil unless current_organization
                    
                        @active_banner = current_organization.banners.active.first
                    Severity: Minor
                    Found in app/controllers/application_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 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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language