class RuboCop::Cop::Migration::Tagged
Public Instance Methods
Source
# File lib/outrigger/cops/migration/tagged.rb, line 7 def on_class(node) _name, _superclass, body = *node return unless body && migration_class?(node) check(node, body) end
Private Instance Methods
Source
# File lib/outrigger/cops/migration/tagged.rb, line 30 def check(klass, node) tag = tag_node(node) if allowed_tags.empty? add_offense tag, location: :expression, message: 'No allowed tags have been defined in the RuboCop configuration.' elsif tag return if allowed_tags.include? tag.children.last.to_a.last add_offense tag, location: :expression, message: "Tags may only be one of #{allowed_tags}." else add_offense klass, location: :expression, message: "All migrations require a tag from #{allowed_tags}." end end
Source
# File lib/outrigger/cops/migration/tagged.rb, line 50 def tag_node(node) node.type == :begin && node.children.compact.find do |n| n.type == :send && n.to_a[1] == :tag end end