Class: RailsBestPractices::Reviews::RemoveUnusedMethodsInModelsReview

Inherits:
Review
  • Object
show all
Includes:
Callable, Classable, Exceptable
Defined in:
lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb

Overview

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.

Constant Summary

Constants inherited from Core::Check

Core::Check::ALL_FILES, Core::Check::CAPFILE, Core::Check::CONFIG_FILES, Core::Check::CONTROLLER_FILES, Core::Check::DEPLOY_FILES, Core::Check::GEMFILE_LOCK, Core::Check::HELPER_FILES, Core::Check::INITIALIZER_FILES, Core::Check::MAILER_FILES, Core::Check::MIGRATION_FILES, Core::Check::MODEL_FILES, Core::Check::PARTIAL_VIEW_FILES, Core::Check::ROUTE_FILES, Core::Check::SCHEMA_FILE, Core::Check::SKIP_FILES, Core::Check::VIEW_FILES

Instance Method Summary collapse

Methods inherited from Review

#model_associations, #model_attributes, #models, #remember_variable_use_count, #reset_variable_use_count, #variable, #variable_use_count

Methods inherited from Core::Check

#add_error, debug, debug?, #errors, #is_ignored?, #is_interesting_file?, #method_missing, #parse_file?, #regex_ignored_files, #url, url

Constructor Details

#initialize(options = {}) ⇒ RemoveUnusedMethodsInModelsReview

Returns a new instance of RemoveUnusedMethodsInModelsReview.



21
22
23
24
# 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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RailsBestPractices::Core::Check

Instance Method Details

#skip_command_callback_nodesObject

skip scope and validate nodes for start_command callbacks.



27
28
29
# 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