Skip to content

Commit

Permalink
don't try to load rubocop in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumebriday authored and pushcx committed Dec 5, 2018
1 parent 3426d6f commit 70e8eef
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions extras/prohibit_safe_navigation.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 70e8eef

Please sign in to comment.