Sha256: 98f799ea173b4f7ad284ca4beca84f66ed0ae379daa4dc7fde8bde1faa6dc102

Contents?: true

Size: 1.03 KB

Versions: 10

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8
require 'rails_best_practices/reviews/review'

module RailsBestPractices
  module Reviews
    # Review view and helper files to make sure not use time_ago_in_words or distance_of_time_in_words_to_now.
    #
    # See the best practice details here http://rails-bestpractices.com/posts/105-not-use-time_ago_in_words.
    #
    # Implementation:
    #
    # Review process:
    #   check all fcall node to see if its message is time_ago_in_words and distance_of_time_in_words_to_now
    class NotUseTimeAgoInWordsReview < Review
      interesting_nodes :fcall
      interesting_files VIEW_FILES, HELPER_FILES
      url "http://rails-bestpractices.com/posts/105-not-use-time_ago_in_words"

      # check fcall node to see if its message is time_ago_in_words or distance_of_time_in_words_to_now
      add_callback :start_fcall do |node|
        if "time_ago_in_words" == node.message.to_s || "distance_of_time_in_words_to_now" == node.message.to_s
          add_error "not use time_ago_in_words"
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rails_best_practices-1.13.8 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.13.5 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.13.4 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.13.3 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.13.2 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.13.1 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.13.0 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.12.0 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.11.1 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.11.0 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb