Sha256: 350e16c460c9ff693b5af6358ad152feaa1c89cbee56ab5f1dcb2ea66220f8b2

Contents?: true

Size: 794 Bytes

Versions: 2

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 'default_scope' == node.message.to_s
          add_error 'default_scope is evil'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_best_practices-1.19.3 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb
rails_best_practices-1.19.2 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb