Auto-fix Style/NegatedIf offenses

This commit is contained in:
Issy Long 2019-10-13 10:14:23 +01:00
parent b87782ef7d
commit 37fee928b5
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
3 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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))

View File

@ -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}