Auto-fix Style/NegatedIf offenses
This commit is contained in:
parent
b87782ef7d
commit
37fee928b5
@ -13,7 +13,7 @@ class Locale
|
|||||||
def self.parse(string)
|
def self.parse(string)
|
||||||
string = string.to_s
|
string = string.to_s
|
||||||
|
|
||||||
raise ParserError, "'#{string}' cannot be parsed to a #{self}" if !LOCALE_REGEX.match?(string)
|
raise ParserError, "'#{string}' cannot be parsed to a #{self}" unless LOCALE_REGEX.match?(string)
|
||||||
|
|
||||||
scan = proc do |regex|
|
scan = proc do |regex|
|
||||||
string.scan(/(?:\-|^)(#{regex})(?:\-|$)/).flatten.first
|
string.scan(/(?:\-|^)(#{regex})(?:\-|$)/).flatten.first
|
||||||
|
|||||||
@ -17,7 +17,7 @@ module RuboCop
|
|||||||
url_node = stanza.stanza_node.first_argument
|
url_node = stanza.stanza_node.first_argument
|
||||||
url = url_node.str_content
|
url = url_node.str_content
|
||||||
|
|
||||||
return if !%r{^.+://[^/]+$}.match?(url)
|
return unless %r{^.+://[^/]+$}.match?(url)
|
||||||
|
|
||||||
add_offense(url_node, location: :expression,
|
add_offense(url_node, location: :expression,
|
||||||
message: format(MSG_NO_SLASH, url: url))
|
message: format(MSG_NO_SLASH, url: url))
|
||||||
|
|||||||
@ -30,7 +30,7 @@ module RuboCop
|
|||||||
patch_url = string_content(patch)
|
patch_url = string_content(patch)
|
||||||
gh_patch_param_pattern = %r{https?://github\.com/.+/.+/(?:commit|pull)/[a-fA-F0-9]*.(?:patch|diff)}
|
gh_patch_param_pattern = %r{https?://github\.com/.+/.+/(?:commit|pull)/[a-fA-F0-9]*.(?:patch|diff)}
|
||||||
if regex_match_group(patch, gh_patch_param_pattern)
|
if regex_match_group(patch, gh_patch_param_pattern)
|
||||||
if !/\?full_index=\w+$/.match?(patch_url)
|
unless /\?full_index=\w+$/.match?(patch_url)
|
||||||
problem <<~EOS
|
problem <<~EOS
|
||||||
GitHub patches should use the full_index parameter:
|
GitHub patches should use the full_index parameter:
|
||||||
#{patch_url}?full_index=1
|
#{patch_url}?full_index=1
|
||||||
@ -43,7 +43,7 @@ module RuboCop
|
|||||||
%r{gist\.github\.com/.+/raw},
|
%r{gist\.github\.com/.+/raw},
|
||||||
%r{gist\.githubusercontent\.com/.+/raw}])
|
%r{gist\.githubusercontent\.com/.+/raw}])
|
||||||
if regex_match_group(patch, gh_patch_patterns)
|
if regex_match_group(patch, gh_patch_patterns)
|
||||||
if !/[a-fA-F0-9]{40}/.match?(patch_url)
|
unless /[a-fA-F0-9]{40}/.match?(patch_url)
|
||||||
problem <<~EOS.chomp
|
problem <<~EOS.chomp
|
||||||
GitHub/Gist patches should specify a revision:
|
GitHub/Gist patches should specify a revision:
|
||||||
#{patch_url}
|
#{patch_url}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user