debian-mirror-gitlab/rubocop/cop/style/regexp_literal_mixed_preserve.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
883 B
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
module RuboCop
module Cop
module Style
# This cop is based on `Style/RegexpLiteral` but adds a new
# `EnforcedStyle` option `mixed_preserve`.
#
# This cop will be removed once the upstream PR is merged and RuboCop upgraded.
#
# See https://github.com/rubocop/rubocop/pull/9688
class RegexpLiteralMixedPreserve < RuboCop::Cop::Style::RegexpLiteral
module Patch
private
def allowed_slash_literal?(node)
super || allowed_mixed_preserve?(node)
end
def allowed_percent_r_literal?(node)
super || allowed_mixed_preserve?(node)
end
def allowed_mixed_preserve?(node)
style == :mixed_preserve && !contains_disallowed_slash?(node)
end
end
prepend Patch
end
end
end
end