class RailsBestPractices::Reviews::UseBeforeFilterReview
Review
a controller file to make sure to use before_filter to remove duplicated first code line_number in different action.
See the best practice detailed here rails-bestpractices.com/posts/2010/07/24/use-before_filter/
Implementation:
Review
process:
check all first code line_number in method definitions (actions), if they are duplicated, then they should be moved to before_filter.
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
RailsBestPractices::Core::Check::new
# File lib/rails_best_practices/reviews/use_before_filter_review.rb, line 21 def initialize(options = {}) super() @customize_count = options['customize_count'] || 2 end
Private Instance Methods
remember_first_sentence(node)
click to toggle source
check method define node, and remember the first sentence.
# File lib/rails_best_practices/reviews/use_before_filter_review.rb, line 53 def remember_first_sentence(node) first_sentence = node.body.statements.first return unless first_sentence first_sentence = first_sentence.remove_line_and_column unless first_sentence == s(:nil) @first_sentences[first_sentence] ||= [] @first_sentences[first_sentence] << node end end