flyerhzm / rails_best_practices

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

Problem with search_data method in model labelled as unused! #352

Closed cdrrazan closed 1 year ago

cdrrazan commented 4 years ago

Upon running and executing rails_best_practices, it labels search_data as unused model method whereas search_data is used from searchkick to control the type of indexing.

  def search_data
    attributes.merge(
      group_id: groups.try(:ids)
    )
  end

This should be ignored!

arieliten commented 3 years ago

@cdrrazan You can fix it by adding those methods in the proper config/rails_best_practices.yml file. In my case, I updated that file with:

RemoveUnusedMethodsInModelsCheck: { except_methods: ['User#search_data'] }

and then it passed. Hope it helps