Skip to content

Commit aa95ee2

Browse files
committed
util/rubocop -A --only Style/NegatedIf
1 parent 823113f commit aa95ee2

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,9 @@ Security/Open:
441441
Security/JSONLoad:
442442
Enabled: true
443443

444+
Style/NegatedIf:
445+
Enabled: true
446+
444447
Style/ColonMethodCall:
445448
Enabled: true
446449

.rubocop_bundler.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ Style/MultilineTernaryOperator:
136136
Style/MultipleComparison:
137137
Enabled: true
138138

139-
Style/NegatedIf:
140-
Enabled: true
141-
142139
Style/NestedModifier:
143140
Enabled: true
144141

lib/rubygems/commands/cert_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def execute
135135
end
136136

137137
def build(email)
138-
if !valid_email?(email)
138+
unless valid_email?(email)
139139
raise Gem::CommandLineError, "Invalid email address #{email}"
140140
end
141141

lib/rubygems/query_utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def check_installed_gems(gem_names)
8484
installed = !installed unless options[:installed]
8585

8686
say(installed)
87-
exit_code = 1 if !installed
87+
exit_code = 1 unless installed
8888
end
8989

9090
exit_code

lib/rubygems/source.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ def <=>(other)
4444
Gem::Source::Vendor then
4545
-1
4646
when Gem::Source then
47-
if !@uri
47+
unless @uri
4848
return 0 unless other.uri
4949
return 1
5050
end
5151

52-
return -1 if !other.uri
52+
return -1 unless other.uri
5353

5454
# Returning 1 here ensures that when sorting a list of sources, the
5555
# original ordering of sources supplied by the user is preserved.

lib/rubygems/specification.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,8 +1616,8 @@ def build_extensions # :nodoc:
16161616
# we need to fresh build when same name and version of default gems
16171617
return if self.class.find_by_full_name(full_name)&.default_gem?
16181618
return if File.exist? gem_build_complete_path
1619-
return if !File.writable?(base_dir)
1620-
return if !File.exist?(File.join(base_dir, "extensions"))
1619+
return unless File.writable?(base_dir)
1620+
return unless File.exist?(File.join(base_dir, "extensions"))
16211621

16221622
begin
16231623
# We need to require things in $LOAD_PATH without looking for the

lib/rubygems/specification_policy.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ def validate_metadata
125125

126126
metadata.each do |key, value|
127127
entry = "metadata['#{key}']"
128-
if !key.is_a?(String)
128+
unless key.is_a?(String)
129129
error "metadata keys must be a String"
130130
end
131131

132132
if key.size > 128
133133
error "metadata key is too large (#{key.size} > 128)"
134134
end
135135

136-
if !value.is_a?(String)
136+
unless value.is_a?(String)
137137
error "#{entry} value must be a String"
138138
end
139139

@@ -368,7 +368,7 @@ def validate_licenses
368368
licenses = @specification.licenses
369369

370370
licenses.each do |license|
371-
if !Gem::Licenses.match?(license)
371+
unless Gem::Licenses.match?(license)
372372
suggestions = Gem::Licenses.suggestions(license)
373373
message = <<-WARNING
374374
license value '#{license}' is invalid. Use a license identifier from

lib/rubygems/user_interaction.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def ask_yes_no(question, default=nil)
281281
# Ask a question. Returns an answer if connected to a tty, nil otherwise.
282282

283283
def ask(question)
284-
return nil if !tty?
284+
return nil unless tty?
285285

286286
@outs.print(question + " ")
287287
@outs.flush
@@ -295,7 +295,7 @@ def ask(question)
295295
# Ask for a password. Does not echo response to terminal.
296296

297297
def ask_for_password(question)
298-
return nil if !tty?
298+
return nil unless tty?
299299

300300
@outs.print(question, " ")
301301
@outs.flush

test/rubygems/test_gem_requirement.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_parse
8383
Gem::Requirement.parse(Gem::Version.new("2"))
8484
end
8585

86-
if !(Gem.java_platform? && ENV["JRUBY_OPTS"].to_s.include?("--debug"))
86+
unless (Gem.java_platform? && ENV["JRUBY_OPTS"].to_s.include?("--debug"))
8787
def test_parse_deduplication
8888
assert_same "~>", Gem::Requirement.parse("~> 1").first
8989
end

0 commit comments

Comments
 (0)