diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-14 00:11:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-14 00:11:25 +0300 |
commit | 5f36333180258e43c88b71047086150b6ca233a4 (patch) | |
tree | 62b80c1edc934309aca3f3eddde766a1c6d94c4f /rubocop/cop | |
parent | a5605d87fb839e0b1015ad9e736c44fbb2ada202 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop/cop')
-rw-r--r-- | rubocop/cop/style/regexp_literal_mixed_preserve.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/rubocop/cop/style/regexp_literal_mixed_preserve.rb b/rubocop/cop/style/regexp_literal_mixed_preserve.rb new file mode 100644 index 00000000000..4dc38d82f45 --- /dev/null +++ b/rubocop/cop/style/regexp_literal_mixed_preserve.rb @@ -0,0 +1,33 @@ +# 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 |