From 70e8eef8d82654aface2547f13a7052b793d2419 Mon Sep 17 00:00:00 2001 From: Guillaume Briday Date: Wed, 5 Dec 2018 15:24:46 +0100 Subject: [PATCH] don't try to load rubocop in prod Fix #599 --- extras/prohibit_safe_navigation.rb | 42 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/extras/prohibit_safe_navigation.rb b/extras/prohibit_safe_navigation.rb index 3d6f97a30..71a0a8088 100644 --- a/extras/prohibit_safe_navigation.rb +++ b/extras/prohibit_safe_navigation.rb @@ -1,25 +1,29 @@ -module RuboCop - module Cop - module Style - # The "safe navigation" operator &. makes it easier to work with and - # propagate nil values. This will disallow the use of the safe navigation - # operator - # - # @example - # - # # bad - # foo&.bar - # a.foo&.bar - # - class DisallowSafeNavigation < Cop - extend TargetRubyVersion +require "rails" - MSG = 'Do not use &.'.freeze +unless Rails.env.production? + module RuboCop + module Cop + module Style + # The "safe navigation" operator &. makes it easier to work with and + # propagate nil values. This will disallow the use of the safe navigation + # operator + # + # @example + # + # # bad + # foo&.bar + # a.foo&.bar + # + class DisallowSafeNavigation < Cop + extend TargetRubyVersion - minimum_target_ruby_version 2.3 + MSG = 'Do not use &.'.freeze - def on_csend(node) - add_offense(node) + minimum_target_ruby_version 2.3 + + def on_csend(node) + add_offense(node) + end end end end