Sha256: cac7f02c20af6ced26321f768265089a1b89083b8c22f664fa4c609551ed7f11

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

# encoding: utf-8
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

1 entries across 1 versions & 1 rubygems

Version Path
rails_best_practices-1.19.1 lib/rails_best_practices/reviews/default_scope_is_evil_review.rb