2019-04-08 13:33:36 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module RuboCop
|
|
|
|
module Cop
|
|
|
|
# Cop that blacklists the use of `reload`.
|
2022-09-14 15:12:56 +00:00
|
|
|
class ActiveRecordAssociationReload < RuboCop::Cop::Base
|
2019-04-08 13:33:36 +00:00
|
|
|
MSG = 'Use reset instead of reload. ' \
|
2019-09-18 14:02:45 +00:00
|
|
|
'For more details check the https://gitlab.com/gitlab-org/gitlab-foss/issues/60218.'
|
2019-04-08 13:33:36 +00:00
|
|
|
|
|
|
|
def_node_matcher :reload?, <<~PATTERN
|
|
|
|
(send _ :reload ...)
|
|
|
|
PATTERN
|
|
|
|
|
|
|
|
def on_send(node)
|
|
|
|
return unless reload?(node)
|
|
|
|
|
2022-09-14 15:12:56 +00:00
|
|
|
add_offense(node.loc.selector)
|
2019-04-08 13:33:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|