Sha256: 2e82997a6a2185587665143c9a65a864121faed0df53a5490302fdd6b8048c77

Contents?: true

Size: 794 Bytes

Versions: 10

Compression:

Stored size: 794 Bytes

Contents

# frozen_string_literal: true

module RailsBestPractices
  module Reviews
    # Review model files to make sure not use default_scope
    #
    # See the best practice details here https://rails-bestpractices.com/posts/2013/06/15/default_scope-is-evil/
    #
    # Implementation:
    #
    # Review process:
    #   check all command node to see if its message is default_scope
    class DefaultScopeIsEvilReview < Review
      interesting_nodes :command
      interesting_files MODEL_FILES
      url 'https://rails-bestpractices.com/posts/2013/06/15/default_scope-is-evil/'

      # check all command nodes' message
      add_callback :start_command do |node|
        if node.message.to_s == 'default_scope'
          add_error 'default_scope is evil'
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rails_best_practices-1.23.2 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
rails_best_practices-1.23.1 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
rails_best_practices-1.23.0 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
rails_best_practices-1.22.1 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
rails_best_practices-1.22.0 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
rails_best_practices-1.21.0 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
rails_best_practices-1.20.1 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
rails_best_practices-1.20.0 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
rails_best_practices-1.19.5 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
rails_best_practices-1.19.4 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb