codeforamerica/michigan-benefits

View on GitHub

Showing 40 of 372 total issues

File mb_form_builder.rb has 548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MbFormBuilder < ActionView::Helpers::FormBuilder
  include ActionView::Helpers::DateHelper

  def mb_input_field(
    method,
Severity: Major
Found in app/helpers/mb_form_builder.rb - About 1 day to fix

    File assistance_application_form.rb has 445 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class AssistanceApplicationForm
      include Integrated::PdfAttributes
    
      def initialize(benefit_application)
        @benefit_application = benefit_application
    Severity: Minor
    Found in app/pdf_components/assistance_application_form.rb - About 6 hrs to fix

      Method attributes has 126 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def attributes
          [
            {
              applying_for_food_assistance: "Yes",
              email: snap_application.email,
      Severity: Major
      Found in app/models/snap_application_attributes.rb - About 5 hrs to fix

        Class SnapApplicationAttributes has 33 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class SnapApplicationAttributes
          include PdfAttributes
        
          def initialize(snap_application:)
            @snap_application = snap_application
        Severity: Minor
        Found in app/models/snap_application_attributes.rb - About 4 hrs to fix

          Class MbFormBuilder has 31 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class MbFormBuilder < ActionView::Helpers::FormBuilder
            include ActionView::Helpers::DateHelper
          
            def mb_input_field(
              method,
          Severity: Minor
          Found in app/helpers/mb_form_builder.rb - About 3 hrs to fix

            Class AssistanceApplicationForm has 30 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class AssistanceApplicationForm
              include Integrated::PdfAttributes
            
              def initialize(benefit_application)
                @benefit_application = benefit_application
            Severity: Minor
            Found in app/pdf_components/assistance_application_form.rb - About 3 hrs to fix

              Class Dhs1171Pdf has 29 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Dhs1171Pdf
                PDF_DIRECTORY = "app/lib/pdfs".freeze
                SOURCE_PDF = "#{PDF_DIRECTORY}/DHS_1171.pdf".freeze
                COVERSHEET_PDF = "#{PDF_DIRECTORY}/DHS_1171_cover_letter.pdf".freeze
                MAXIMUM_HOUSEHOLD_MEMBERS = 6
              Severity: Minor
              Found in app/models/dhs1171_pdf.rb - About 3 hrs to fix

                Class Member has 28 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Member < ApplicationRecord
                  include SocialSecurityNumber
                
                  PAYMENT_INTERVALS = [
                    "Hourly",
                Severity: Minor
                Found in app/models/member.rb - About 3 hrs to fix

                  Class StepsController has 27 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class StepsController < ApplicationController
                    layout "step"
                  
                    before_action :ensure_application_present, only: %i(edit index update)
                    before_action :maybe_skip, only: :edit
                  Severity: Minor
                  Found in app/controllers/steps_controller.rb - About 3 hrs to fix

                    Method to_h has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def to_h
                        member_attributes = {
                          :"#{position}_member_full_name" => member.display_name,
                          :"#{position}_member_sex_male" => bool_to_checkbox(member.male?),
                          :"#{position}_member_sex_female" => bool_to_checkbox(member.female?),
                    Severity: Major
                    Found in app/models/medicaid_application_member_attributes.rb - About 3 hrs to fix

                      Method applicant_registration_attributes has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def applicant_registration_attributes
                          {
                            applying_for_food: yes_if_true(benefit_application.primary_member.requesting_food_yes?),
                            applying_for_healthcare: yes_if_true(benefit_application.primary_member.requesting_healthcare_yes?),
                            legal_name: benefit_application.display_name,
                      Severity: Major
                      Found in app/pdf_components/assistance_application_form.rb - About 2 hrs to fix

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

                        class Dhs1426Pdf
                          PDF_DIRECTORY = "app/lib/pdfs".freeze
                          SOURCE_PDF = "#{PDF_DIRECTORY}/DHS_1426.pdf".freeze
                          COVERSHEET_PDF = "#{PDF_DIRECTORY}/DHS_1426_cover_letter.pdf".freeze
                          STEP_2_ADDITIONAL_MEMBER_PDF =
                        Severity: Minor
                        Found in app/models/dhs1426_pdf.rb - About 2 hrs to fix

                          File snap_application_attributes.rb has 266 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          class SnapApplicationAttributes
                            include PdfAttributes
                          
                            def initialize(snap_application:)
                              @snap_application = snap_application
                          Severity: Minor
                          Found in app/models/snap_application_attributes.rb - About 2 hrs to fix

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

                            class FormsController < ApplicationController
                              layout "form"
                            
                              before_action :ensure_application_present, only: %i[edit update]
                            
                            
                            Severity: Minor
                            Found in app/controllers/forms_controller.rb - About 2 hrs to fix

                              Method attributes has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def attributes
                                  [
                                    {
                                      signature: medicaid_application.signature,
                                      signature_date: mmddyyyy_date(medicaid_application.signed_at),
                              Severity: Minor
                              Found in app/models/medicaid_application_attributes.rb - About 1 hr to fix

                                Method add_additional_members_employed has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def add_additional_members_employed
                                    jobs = benefit_application.members.map(&:employments).flatten
                                    if jobs.count > 2
                                      @_additional_notes[:household_added_notes] = "Yes"
                                      @_additional_notes[:notes] += "Additional Jobs:\n"
                                Severity: Minor
                                Found in app/pdf_components/assistance_application_form.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 uploadSetup has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                var uploadSetup = function (previewTemplate) {
                                  new Shubox('#uploadables-drop', {
                                    previewsContainer: '.form-card__uploadables',
                                    clickable: '#click-to-upload',
                                    previewTemplate: previewTemplate,
                                Severity: Minor
                                Found in app/assets/javascripts/upload_setup.js - About 1 hr to fix

                                  Method execute_callstack_for_multiparameter_attributes has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    def execute_callstack_for_multiparameter_attributes(callstack)
                                      # Disabling Rubcop below because Brakeman is failing to parse the
                                      #  when we remove the 'begin' keyword
                                      # rubocop:disable Style/RedundantBegin
                                      errors = []
                                  Severity: Minor
                                  Found in app/models/concerns/multiparameter_attribute_assignment.rb - About 1 hr to fix

                                    Method mb_checkbox_set_with_none has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      def mb_checkbox_set_with_none(
                                        method,
                                        collection,
                                        label_text: nil,
                                        value_is_array: false,
                                    Severity: Minor
                                    Found in app/helpers/mb_form_builder.rb - About 1 hr to fix

                                      Method index has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          def index
                                            snap_apps = SnapApplication.signed
                                            medicaid_apps = MedicaidApplication.signed
                                            common_apps = CommonApplication.signed
                                      
                                      
                                      Severity: Minor
                                      Found in app/controllers/stats/numbers_controller.rb - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language