-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7697 from Homebrew/dependabot/bundler/Library/Hom…
…ebrew/rubocop-performance-1.6.1 build(deps): bump rubocop-performance from 1.6.0 to 1.6.1 in /Library/Homebrew
- Loading branch information
Showing
38 changed files
with
202 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
...e/ruby/2.6.0/gems/rubocop-performance-1.6.0/lib/rubocop/cop/mixin/regexp_metacharacter.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
76 changes: 76 additions & 0 deletions
76
...e/ruby/2.6.0/gems/rubocop-performance-1.6.1/lib/rubocop/cop/mixin/regexp_metacharacter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# frozen_string_literal: true | ||
|
||
module RuboCop | ||
module Cop | ||
# Common functionality for handling regexp metacharacters. | ||
module RegexpMetacharacter | ||
private | ||
|
||
def literal_at_start?(regexp) | ||
return true if literal_at_start_with_backslash_a?(regexp) | ||
|
||
!safe_multiline? && literal_at_start_with_caret?(regexp) | ||
end | ||
|
||
def literal_at_end?(regexp) | ||
return true if literal_at_end_with_backslash_z?(regexp) | ||
|
||
!safe_multiline? && literal_at_end_with_dollar?(regexp) | ||
end | ||
|
||
def literal_at_start_with_backslash_a?(regex_str) | ||
# is this regexp 'literal' in the sense of only matching literal | ||
# chars, rather than using metachars like `.` and `*` and so on? | ||
# also, is it anchored at the start of the string? | ||
# (tricky: \s, \d, and so on are metacharacters, but other characters | ||
# escaped with a slash are just literals. LITERAL_REGEX takes all | ||
# that into account.) | ||
/\A\\A(?:#{Util::LITERAL_REGEX})+\z/.match?(regex_str) | ||
end | ||
|
||
def literal_at_start_with_caret?(regex_str) | ||
# is this regexp 'literal' in the sense of only matching literal | ||
# chars, rather than using metachars like `.` and `*` and so on? | ||
# also, is it anchored at the start of the string? | ||
# (tricky: \s, \d, and so on are metacharacters, but other characters | ||
# escaped with a slash are just literals. LITERAL_REGEX takes all | ||
# that into account.) | ||
/\A\^(?:#{Util::LITERAL_REGEX})+\z/.match?(regex_str) | ||
end | ||
|
||
def literal_at_end_with_backslash_z?(regex_str) | ||
# is this regexp 'literal' in the sense of only matching literal | ||
# chars, rather than using metachars like . and * and so on? | ||
# also, is it anchored at the end of the string? | ||
/\A(?:#{Util::LITERAL_REGEX})+\\z\z/.match?(regex_str) | ||
end | ||
|
||
def literal_at_end_with_dollar?(regex_str) | ||
# is this regexp 'literal' in the sense of only matching literal | ||
# chars, rather than using metachars like . and * and so on? | ||
# also, is it anchored at the end of the string? | ||
/\A(?:#{Util::LITERAL_REGEX})+\$\z/.match?(regex_str) | ||
end | ||
|
||
def drop_start_metacharacter(regexp_string) | ||
if regexp_string.start_with?('\\A') | ||
regexp_string[2..-1] # drop `\A` anchor | ||
else | ||
regexp_string[1..-1] # drop `^` anchor | ||
end | ||
end | ||
|
||
def drop_end_metacharacter(regexp_string) | ||
if regexp_string.end_with?('\\z') | ||
regexp_string.chomp('\z') # drop `\z` anchor | ||
else | ||
regexp_string.chop # drop `$` anchor | ||
end | ||
end | ||
|
||
def safe_multiline? | ||
cop_config.fetch('SafeMultiline', true) | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.