flyerhzm / rails_best_practices

a code metric tool for rails projects
http://rails-bestpractices.com
MIT License
4.16k stars 276 forks source link

`RemoveUnusedMethodsInHelpersCheck` marks helper methods as unused after upgrade from HAML 5 to 6 #396

Open oliverklee opened 1 year ago

oliverklee commented 1 year ago

For our (private) project, we're currently in the process of upgrade from HAML 5 to 6.

After the upgrade, RBP marks all of our helper methods which we use in our HAML templates as unused.

This is an example:

##
# Icon view helper.
#
module IconViewHelper
  ##
  # Creates HTML for icons including screen reader texts.
  #
  # This method rightfully has a :reek:ControlParameter.
  #
  # @param [Boolean] icon_type true for "yes" and false for "no"
  #
  # @return [String] the rendered HTML
  #
  def icon_yes_or_no(icon_type)
    icon = icon_type ? 'check' : 'times'
    screen_reader_text_key = icon_type ? 'yes' : 'no'

    render partial: 'shared/accessible_icon', locals: {
      icon_file_name: icon,
      screen_reader_text: t("views.#{screen_reader_text_key}")
    }
  end
end
%td{ data: { scope: 'is-active' },
    content: organization.offerer.active?.to_s }
   != icon_yes_or_no organization.offerer.active?