2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-03 11:08:47 +01:00
|
|
|
if defined?(RuboCop)
|
2020-01-30 15:14:33 +01:00
|
|
|
module RuboCop
|
|
|
|
module Cop
|
|
|
|
module DS
|
|
|
|
class Unscoped < Cop
|
|
|
|
MSG = "Avoid using `unscoped`. Instead unscope specific clauses by using `unscope(where: :attribute)`."
|
2020-01-28 16:58:34 +01:00
|
|
|
|
2020-01-30 15:14:33 +01:00
|
|
|
def_node_matcher :unscoped?, <<-END
|
|
|
|
(send _ :unscoped)
|
|
|
|
END
|
2020-01-28 16:58:34 +01:00
|
|
|
|
2020-01-30 15:14:33 +01:00
|
|
|
def on_send(node)
|
|
|
|
return unless unscoped?(node)
|
|
|
|
add_offense(node)
|
|
|
|
end
|
2020-01-28 16:58:34 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|