class RailsBestPractices::Reviews::RemoveUnusedMethodsInModelsReview

Find out unused methods in models.

Implemenation:

Review process:

remember all method calls,
at end, check if all defined methods are called,
if not, non called methods are unused.

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method
# File lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb, line 21
def initialize(options = {})
  super
  @model_methods = Prepares.model_methods
end

Public Instance Methods

skip_command_callback_nodes() click to toggle source

skip scope and validate nodes for start_command callbacks.

# File lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb, line 27
def skip_command_callback_nodes
  %w[named_scope scope validate validate_on_create validate_on_update]
end

Protected Instance Methods

internal_except_methods() click to toggle source
# File lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb, line 97
def internal_except_methods
  %w[
    initialize
    validate
    validate_each
    validate_on_create
    validate_on_update
    human_attribute_name
    assign_attributes
    attributes
    attribute
    to_xml
    to_json
    as_json
    to_param
    before_save
    before_create
    before_update
    before_destroy
    after_save
    after_create
    after_update
    after_destroy
    after_find
    after_initialize
    method_missing
    table_name
    module_prefix
  ].map { |method_name| "*\##{method_name}" }
end
methods() click to toggle source
# File lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb, line 93
def methods
  @model_methods
end