Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve new chefstyle warnings & use safe navigators #1507

Merged
merged 4 commits into from Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ohai/plugins/ec2.rb
Expand Up @@ -114,7 +114,7 @@ def looks_like_ec2?
end

collect_data do
require "base64"
require "base64" unless defined?(Base64)

if looks_like_ec2?
logger.trace("Plugin EC2: looks_like_ec2? == true")
Expand Down
8 changes: 3 additions & 5 deletions lib/ohai/plugins/linux/network.rb
Expand Up @@ -141,11 +141,9 @@ def check_routing_table(family, iface, default_route_table)
# using a temporary var to hold routes and their interface name
def parse_routes(family, iface)
iface.collect do |i, iv|
if iv[:routes]
iv[:routes].collect do |r|
r.merge(dev: i) if r[:family] == family[:name]
end.compact
end
iv[:routes]&.collect do |r|
r.merge(dev: i) if r[:family] == family[:name]
end&.compact
end.compact.flatten
end

Expand Down
2 changes: 1 addition & 1 deletion lib/ohai/plugins/shard.rb
Expand Up @@ -52,7 +52,7 @@ def default_digest_algorithm
def digest_algorithm
case Ohai.config[:plugin][:shard_seed][:digest_algorithm] || default_digest_algorithm
when "md5"
require "digest/md5"
require "digest/md5" unless defined?(Digest::MD5)
Digest::MD5
when "sha256"
require "openssl/digest"
Expand Down
2 changes: 1 addition & 1 deletion lib/ohai/plugins/softlayer.rb
Expand Up @@ -39,7 +39,7 @@ def looks_like_softlayer?
logger.trace("Plugin Softlayer: looks_like_softlayer? == true")
metadata = fetch_metadata
softlayer Mash.new
metadata.each { |k, v| softlayer[k] = v } if metadata
metadata&.each { |k, v| softlayer[k] = v }
else
logger.trace("Plugin Softlayer: looks_like_softlayer? == false")
end
Expand Down
12 changes: 5 additions & 7 deletions lib/ohai/plugins/solaris2/network.rb
Expand Up @@ -86,7 +86,7 @@ def arpname_to_ifname(iface, arpname)

def full_interface_name(iface, part_name, index)
iface.each do |name, attrs|
next unless attrs && attrs.respond_to?(:[])
next unless attrs&.respond_to?(:[])
tas50 marked this conversation as resolved.
Show resolved Hide resolved
return name if /^#{part_name}($|:)/.match(name) && attrs[:index] == index
end

Expand Down Expand Up @@ -155,12 +155,10 @@ def full_interface_name(iface, part_name, index)
break
end
end
if iface[ifn][:arp]
iface[ifn][:arp].each_key do |addr|
if addr.eql?(iaddr)
iface[ifn][:addresses][iface[ifn][:arp][iaddr]] = { "family" => "lladdr" }
break
end
iface[ifn][:arp]&.each_key do |addr|
if addr.eql?(iaddr)
iface[ifn][:addresses][iface[ifn][:arp][iaddr]] = { "family" => "lladdr" }
break
end
tas50 marked this conversation as resolved.
Show resolved Hide resolved
end
end
Expand Down