From eb20dd9153157c995f581a38f5d3005d71838018 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 30 Jan 2020 15:14:33 +0100 Subject: [PATCH] only load unscoped custom rule in development --- lib/cops/unscoped.rb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/cops/unscoped.rb b/lib/cops/unscoped.rb index 8374c2116..2cbfe5f98 100644 --- a/lib/cops/unscoped.rb +++ b/lib/cops/unscoped.rb @@ -1,16 +1,18 @@ -module RuboCop - module Cop - module DS - class Unscoped < Cop - MSG = "Avoid using `unscoped`. Instead unscope specific clauses by using `unscope(where: :attribute)`." +if ENV["RAILS_ENV"] == "development" + module RuboCop + module Cop + module DS + class Unscoped < Cop + MSG = "Avoid using `unscoped`. Instead unscope specific clauses by using `unscope(where: :attribute)`." - def_node_matcher :unscoped?, <<-END - (send _ :unscoped) - END + def_node_matcher :unscoped?, <<-END + (send _ :unscoped) + END - def on_send(node) - return unless unscoped?(node) - add_offense(node) + def on_send(node) + return unless unscoped?(node) + add_offense(node) + end end end end