Class: RailsBestPractices::Reviews::RemoveUnusedMethodsInControllersReview

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

Overview

Find out unused methods in controllers.

Implementation:

Review process:

remember all method calls in controllers,
if they are not defined in routes,
and they are not called in controllers,
then they are the unused methods in controllers.

Constant Summary collapse

INHERITED_RESOURCES_METHODS =
%w[resource collection begin_of_association_chain build_resource].freeze

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 = {}) ⇒ RemoveUnusedMethodsInControllersReview

Returns a new instance of RemoveUnusedMethodsInControllersReview.



27
28
29
30
31
32
# File 'lib/rails_best_practices/reviews/remove_unused_methods_in_controllers_review.rb', line 27

def initialize(options = {})
  super
  @controller_methods = Prepares.controller_methods
  @routes = Prepares.routes
  @inherited_resources = false
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 render and around_filter nodes for start_command callbacks.



48
49
50
# File 'lib/rails_best_practices/reviews/remove_unused_methods_in_controllers_review.rb', line 48

def skip_command_callback_nodes
  %w[render_cell render around_filter]
end