Skip to content

Commit d13fbb1

Browse files
committed
(PUP-11993) Style/NonNilCheck
This commit enables the Style/NonNilCheck cop and fixes 4 autocorrectable offenses.
1 parent eaca32a commit d13fbb1

File tree

5 files changed

+4
-13
lines changed

5 files changed

+4
-13
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -629,15 +629,6 @@ Style/MultipleComparison:
629629
Style/MutableConstant:
630630
Enabled: false
631631

632-
# This cop supports safe auto-correction (--auto-correct).
633-
# Configuration parameters: IncludeSemanticChanges.
634-
Style/NonNilCheck:
635-
Exclude:
636-
- 'lib/puppet/forge.rb'
637-
- 'lib/puppet/http/session.rb'
638-
- 'lib/puppet/network/http/request.rb'
639-
- 'lib/puppet/provider/package/pip.rb'
640-
641632
# This cop supports safe auto-correction (--auto-correct).
642633
Style/Not:
643634
Enabled: false

lib/puppet/forge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def unpack(file, destination)
235235
end
236236

237237
def deprecated?
238-
@data['module'] && (@data['module']['deprecated_at'] != nil)
238+
@data['module'] && (!@data['module']['deprecated_at'].nil?)
239239
end
240240
end
241241

lib/puppet/http/session.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def route_to(name, url: nil, ssl_context: nil)
5252
raise ArgumentError, "Unknown service #{name}" unless Puppet::HTTP::Service.valid_name?(name)
5353

5454
# short circuit if explicit URL host & port given
55-
if url && url.host != nil && !url.host.empty?
55+
if url && !url.host.nil? && !url.host.empty?
5656
service = Puppet::HTTP::Service.create_service(@client, self, name, url.host, url.port)
5757
service.connect(ssl_context: ssl_context)
5858
return service

lib/puppet/network/http/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ def response_formatters_for(supported_formats, default_accepted_formats = nil)
7878

7979
def valid_network_format?(format)
8080
# YAML in network requests is not supported. See http://links.puppet.com/deprecate_yaml_on_network
81-
format != nil && format.name != :yaml && format.name != :b64_zlib_yaml
81+
!format.nil? && format.name != :yaml && format.name != :b64_zlib_yaml
8282
end
8383
end

lib/puppet/provider/package/pip.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def self.specificity
3232
# Required by Puppet::Provider::Package::Targetable::resource_or_provider_command
3333
def self.provider_command
3434
# Ensure pip can upgrade pip, which usually puts pip into a new path /usr/local/bin/pip (compared to /usr/bin/pip)
35-
self.cmd.map { |c| which(c) }.find { |c| c != nil }
35+
self.cmd.map { |c| which(c) }.find { |c| !c.nil? }
3636
end
3737

3838
def self.cmd

0 commit comments

Comments
 (0)