33 lines
679 B
Ruby
33 lines
679 B
Ruby
require "rails"
|
|
require "rubocop"
|
|
|
|
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
|
|
|
|
MSG = "Do not use &.".freeze
|
|
|
|
minimum_target_ruby_version 2.3
|
|
|
|
def on_csend(node)
|
|
add_offense(node)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|