diff options
author | Tim Smith <tsmith@chef.io> | 2020-09-08 20:38:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-08 20:38:01 -0700 |
commit | 31e9598d4dad6e66409db4358dec0a06f88de33d (patch) | |
tree | 6e6b6dbbd8b83faf47eccf72cfcd3976c3454a02 | |
parent | 6fefe9971a84dcf5d8b3a0fcdce249d946e3f63e (diff) | |
parent | 7b66dd87433b7b31f085adadbe649b77937a2643 (diff) | |
download | ohai-31e9598d4dad6e66409db4358dec0a06f88de33d.tar.gz |
Merge pull request #1508 from chef/rubocop_RedundantParentheses
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/mixin/do_metadata.rb | 2 | ||||
-rw-r--r-- | lib/ohai/mixin/scaleway_metadata.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/aix/memory.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/bsd/virtualization.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/cloud.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/cpu.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/darwin/platform.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/kernel.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/linux/network.rb | 4 | ||||
-rw-r--r-- | spec/unit/mixin/dmi_decode_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/plugins/bsd/virtualization_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/plugins/netbsd/kernel_spec.rb | 2 |
12 files changed, 15 insertions, 15 deletions
diff --git a/lib/ohai/mixin/do_metadata.rb b/lib/ohai/mixin/do_metadata.rb index b23d2b58..b390b2ed 100644 --- a/lib/ohai/mixin/do_metadata.rb +++ b/lib/ohai/mixin/do_metadata.rb @@ -28,7 +28,7 @@ module Ohai end def fetch_metadata - uri = (DO_METADATA_URL).to_s + uri = DO_METADATA_URL.to_s response = http_client.get(uri) case response.code when "200" diff --git a/lib/ohai/mixin/scaleway_metadata.rb b/lib/ohai/mixin/scaleway_metadata.rb index 9b09f7d4..cef5beb6 100644 --- a/lib/ohai/mixin/scaleway_metadata.rb +++ b/lib/ohai/mixin/scaleway_metadata.rb @@ -32,7 +32,7 @@ module Ohai # # @return [Hash] def fetch_metadata - uri = (SCALEWAY_METADATA_URL).to_s + uri = SCALEWAY_METADATA_URL.to_s response = http_client.get(uri) case response.code when "200" diff --git a/lib/ohai/plugins/aix/memory.rb b/lib/ohai/plugins/aix/memory.rb index e209e14a..b4832a63 100644 --- a/lib/ohai/plugins/aix/memory.rb +++ b/lib/ohai/plugins/aix/memory.rb @@ -30,7 +30,7 @@ Ohai.plugin(:Memory) do memory[:free] = "#{free_in_mb.to_i * 1024}kB" swap_info = shell_out("swap -s").stdout.split # returns swap info in 4K blocks - memory[:swap]["total"] = "#{(swap_info[2].to_i) * 4}kB" - memory[:swap]["free"] = "#{(swap_info[10].to_i) * 4}kB" + memory[:swap]["total"] = "#{swap_info[2].to_i * 4}kB" + memory[:swap]["free"] = "#{swap_info[10].to_i * 4}kB" end end diff --git a/lib/ohai/plugins/bsd/virtualization.rb b/lib/ohai/plugins/bsd/virtualization.rb index f77ea704..f1f03ea2 100644 --- a/lib/ohai/plugins/bsd/virtualization.rb +++ b/lib/ohai/plugins/bsd/virtualization.rb @@ -49,7 +49,7 @@ Ohai.plugin(:Virtualization) do end # detect from modules - so = shell_out((Ohai.abs_path("/sbin/kldstat")).to_s) + so = shell_out(Ohai.abs_path("/sbin/kldstat").to_s) so.stdout.lines do |line| case line when /vboxdrv/ diff --git a/lib/ohai/plugins/cloud.rb b/lib/ohai/plugins/cloud.rb index d6df2571..9570b712 100644 --- a/lib/ohai/plugins/cloud.rb +++ b/lib/ohai/plugins/cloud.rb @@ -100,7 +100,7 @@ Ohai.plugin(:Cloud) do @cloud[:local_ipv6] = @cloud[:local_ipv6_addrs][0] if @cloud[:local_ipv6_addrs] # if empty, return nil - (@cloud.empty?) ? nil : @cloud + @cloud.empty? ? nil : @cloud end private diff --git a/lib/ohai/plugins/cpu.rb b/lib/ohai/plugins/cpu.rb index c7f56ff9..d223405d 100644 --- a/lib/ohai/plugins/cpu.rb +++ b/lib/ohai/plugins/cpu.rb @@ -61,7 +61,7 @@ Ohai.plugin(:CPU) do cpu_number += 1 when /vendor_id\s+:\s(.+)/ vendor_id = $1 - if vendor_id =~ (%r{IBM/S390}) + if vendor_id.include?("IBM/S390") cpuinfo["vendor_id"] = vendor_id else cpuinfo[current_cpu]["vendor_id"] = vendor_id diff --git a/lib/ohai/plugins/darwin/platform.rb b/lib/ohai/plugins/darwin/platform.rb index 439588f5..c744ad53 100644 --- a/lib/ohai/plugins/darwin/platform.rb +++ b/lib/ohai/plugins/darwin/platform.rb @@ -20,7 +20,7 @@ Ohai.plugin(:Platform) do provides "platform", "platform_version", "platform_build", "platform_family" collect_data(:darwin) do - so = shell_out((Ohai.abs_path( "/usr/bin/sw_vers" )).to_s) + so = shell_out(Ohai.abs_path( "/usr/bin/sw_vers" ).to_s) so.stdout.lines do |line| case line when /^ProductVersion:\s+(.+)$/ diff --git a/lib/ohai/plugins/kernel.rb b/lib/ohai/plugins/kernel.rb index 826d5a13..6fdfc1fd 100644 --- a/lib/ohai/plugins/kernel.rb +++ b/lib/ohai/plugins/kernel.rb @@ -42,7 +42,7 @@ Ohai.plugin(:Kernel) do # @return [Mash] def bsd_modules(path) modules = Mash.new - so = shell_out((Ohai.abs_path(path)).to_s) + so = shell_out(Ohai.abs_path(path).to_s) so.stdout.lines do |line| # 1 7 0xc0400000 97f830 kernel if line =~ /(\d+)\s+(\d+)\s+([0-9a-fx]+)\s+([0-9a-fx]+)\s+([a-zA-Z0-9\_]+)/ diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb index 1f8b8693..f5008be0 100644 --- a/lib/ohai/plugins/linux/network.rb +++ b/lib/ohai/plugins/linux/network.rb @@ -264,7 +264,7 @@ Ohai.plugin(:Network) do end key, val = line.split(/:\s+/) if val - coalesce_key = "#{key.downcase.tr(" ", "_")}" + coalesce_key = key.downcase.tr(" ", "_").to_s iface[tmp_int]["coalesce_params"][coalesce_key] = val.to_i end end @@ -289,7 +289,7 @@ Ohai.plugin(:Network) do if val.nil? val = "" end - driver_key = "#{key.downcase.tr(" ", "_")}" + driver_key = key.downcase.tr(" ", "_").to_s iface[tmp_int]["driver_info"][driver_key] = val.chomp end end diff --git a/spec/unit/mixin/dmi_decode_spec.rb b/spec/unit/mixin/dmi_decode_spec.rb index a14cc749..656bc721 100644 --- a/spec/unit/mixin/dmi_decode_spec.rb +++ b/spec/unit/mixin/dmi_decode_spec.rb @@ -38,7 +38,7 @@ describe Ohai::Mixin::DmiDecode, "guest_from_dmi_data" do }.each_pair do |hypervisor, values| describe "when passed #{hypervisor} dmi data" do it "returns '#{hypervisor}'" do - expect(mixin.guest_from_dmi_data(values[0], values[1], values[2])).to eq("#{hypervisor}") + expect(mixin.guest_from_dmi_data(values[0], values[1], values[2])).to eq(hypervisor.to_s) end end end diff --git a/spec/unit/plugins/bsd/virtualization_spec.rb b/spec/unit/plugins/bsd/virtualization_spec.rb index 051b24da..db2ed2e1 100644 --- a/spec/unit/plugins/bsd/virtualization_spec.rb +++ b/spec/unit/plugins/bsd/virtualization_spec.rb @@ -24,7 +24,7 @@ describe Ohai::System, "BSD virtualization plugin" do before do allow(plugin).to receive(:collect_os).and_return(:freebsd) allow(plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", "")) - allow(plugin).to receive(:shell_out).with((Ohai.abs_path( "/sbin/kldstat" )).to_s).and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with(Ohai.abs_path( "/sbin/kldstat" ).to_s).and_return(mock_shell_out(0, "", "")) allow(plugin).to receive(:shell_out).with("jls -nd").and_return(mock_shell_out(0, "", "")) allow(plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, "", "")) allow(plugin).to receive(:shell_out).with("sysctl -n kern.vm_guest").and_return(mock_shell_out(0, "", "")) @@ -79,7 +79,7 @@ describe Ohai::System, "BSD virtualization plugin" do 1 40 0xffffffff80100000 d20428 kernel 7 3 0xffffffff81055000 41e88 vboxguest.ko OUT - allow(plugin).to receive(:shell_out).with((Ohai.abs_path("/sbin/kldstat")).to_s).and_return(mock_shell_out(0, @vbox_guest, "")) + allow(plugin).to receive(:shell_out).with(Ohai.abs_path("/sbin/kldstat").to_s).and_return(mock_shell_out(0, @vbox_guest, "")) end it "detects we are a guest" do diff --git a/spec/unit/plugins/netbsd/kernel_spec.rb b/spec/unit/plugins/netbsd/kernel_spec.rb index 77803103..4946ffd0 100644 --- a/spec/unit/plugins/netbsd/kernel_spec.rb +++ b/spec/unit/plugins/netbsd/kernel_spec.rb @@ -25,7 +25,7 @@ describe Ohai::System, "NetBSD kernel plugin" do allow(@plugin).to receive(:init_kernel).and_return({}) allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", "")) allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", "")) - allow(@plugin).to receive(:shell_out).with((Ohai.abs_path( "/usr/bin/modstat" )).to_s).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", "")) + allow(@plugin).to receive(:shell_out).with(Ohai.abs_path( "/usr/bin/modstat" ).to_s).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", "")) end it "sets the kernel_os to the kernel_name value" do |