Skip to content

Commit

Permalink
Merge pull request #1507 from chef/chefstyle
Browse files Browse the repository at this point in the history
Resolve new chefstyle warnings & use safe navigators
  • Loading branch information
tas50 committed Sep 8, 2020
2 parents 80737ed + 0834783 commit 0478c40
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
12 changes: 6 additions & 6 deletions lib/ohai/plugins/linux/network.rb
Expand Up @@ -141,12 +141,12 @@ 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
end.compact.flatten
next unless iv[:routes]

iv[:routes].collect do |r|
r.merge(dev: i) if r[:family] == family[:name]
end.compact # @todo: when we drop ruby 2.6 this should be a filter_map
end.compact.flatten # @todo: when we drop ruby 2.6 this should be a filter_map
end

# determine layer 1 details for the interface using ethtool
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?(:[])
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
end
end
Expand Down

0 comments on commit 0478c40

Please sign in to comment.