meet the new cop, same as the old cop
This commit is contained in:
parent
0b578ac8ca
commit
c6759f3780
|
@ -1,21 +1,25 @@
|
|||
module RuboCop
|
||||
module Cop
|
||||
module Style
|
||||
class DisallowFormForandFormTag < Cop
|
||||
MSG = 'Use `.form_with` and remove the `.form_tag` and `.form_for`'.freeze
|
||||
require "rails"
|
||||
|
||||
def_node_matcher :form_for_exists?, <<-PATTERN
|
||||
(send _ :form_for ...)
|
||||
PATTERN
|
||||
unless Rails.env.production?
|
||||
module RuboCop
|
||||
module Cop
|
||||
module Style
|
||||
class DisallowFormForandFormTag < Cop
|
||||
MSG = 'Use `.form_with` and remove the `.form_tag` and `.form_for`'.freeze
|
||||
|
||||
def_node_matcher :form_tag_exists?, <<-PATTERN
|
||||
(send _ :form_tag ...)
|
||||
PATTERN
|
||||
def_node_matcher :form_for_exists?, <<-PATTERN
|
||||
(send _ :form_for ...)
|
||||
PATTERN
|
||||
|
||||
def on_send(node)
|
||||
return unless form_for_exists?(node) || form_tag_exists?(node)
|
||||
def_node_matcher :form_tag_exists?, <<-PATTERN
|
||||
(send _ :form_tag ...)
|
||||
PATTERN
|
||||
|
||||
add_offense(node)
|
||||
def on_send(node)
|
||||
return unless form_for_exists?(node) || form_tag_exists?(node)
|
||||
|
||||
add_offense(node)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue