From 5590a185ecd53786bee60051192870eaf59db609 Mon Sep 17 00:00:00 2001 From: Patrick Riehecky Date: Thu, 24 Aug 2023 16:18:10 -0500 Subject: [PATCH] Rubocop -A --- .../provider/firewalld_custom_service/firewall_cmd.rb | 2 +- lib/puppet/provider/firewalld_policy/firewall_cmd.rb | 2 +- lib/puppet/provider/firewalld_zone/firewall_cmd.rb | 2 +- lib/puppet/type/firewalld_ipset.rb | 4 ++-- lib/puppet/type/firewalld_policy.rb | 2 +- spec/classes/init_spec.rb | 2 +- .../unit/puppet/provider/firewalld_custom_service_spec.rb | 4 ++-- spec/unit/puppet/type/firewalld_policy_spec.rb | 8 ++++---- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/puppet/provider/firewalld_custom_service/firewall_cmd.rb b/lib/puppet/provider/firewalld_custom_service/firewall_cmd.rb index f2ea1a9b..77bea5f3 100644 --- a/lib/puppet/provider/firewalld_custom_service/firewall_cmd.rb +++ b/lib/puppet/provider/firewalld_custom_service/firewall_cmd.rb @@ -218,7 +218,7 @@ def destinations return @destinations if @destinations @destinations = execute_firewall_cmd(['--service', @resource[:name], '--get-destinations'], nil).strip.split(%r{\s+}) - @destinations = @destinations.map { |x| x.split(':', 2) }.to_h + @destinations = @destinations.to_h { |x| x.split(':', 2) } @destinations end diff --git a/lib/puppet/provider/firewalld_policy/firewall_cmd.rb b/lib/puppet/provider/firewalld_policy/firewall_cmd.rb index 7d488701..3a8bb53f 100644 --- a/lib/puppet/provider/firewalld_policy/firewall_cmd.rb +++ b/lib/puppet/provider/firewalld_policy/firewall_cmd.rb @@ -43,7 +43,7 @@ def target policy_target end - def target=(_t) + def target=(__target) debug("Setting target for policy #{@resource[:name]} to #{@resource[:target]}") execute_firewall_cmd_policy(['--set-target', @resource[:target]]) end diff --git a/lib/puppet/provider/firewalld_zone/firewall_cmd.rb b/lib/puppet/provider/firewalld_zone/firewall_cmd.rb index ac871c6b..447fcd38 100644 --- a/lib/puppet/provider/firewalld_zone/firewall_cmd.rb +++ b/lib/puppet/provider/firewalld_zone/firewall_cmd.rb @@ -42,7 +42,7 @@ def target zone_target end - def target=(_t) + def target=(__target) debug("Setting target for zone #{@resource[:name]} to #{@resource[:target]}") execute_firewall_cmd(['--set-target', @resource[:target]]) end diff --git a/lib/puppet/type/firewalld_ipset.rb b/lib/puppet/type/firewalld_ipset.rb index 71fa63fb..ee0c972b 100644 --- a/lib/puppet/type/firewalld_ipset.rb +++ b/lib/puppet/type/firewalld_ipset.rb @@ -13,10 +13,10 @@ } " - def po2?(n) + def po2?(num) # A power of two value in binary representation only has one "1" in it. # ie. 01 10, 100 etc. are all power of 2. - n.to_s(2).count('1') == 1 + num.to_s(2).count('1') == 1 end ensurable do diff --git a/lib/puppet/type/firewalld_policy.rb b/lib/puppet/type/firewalld_policy.rb index e09568c6..0ef7defa 100644 --- a/lib/puppet/type/firewalld_policy.rb +++ b/lib/puppet/type/firewalld_policy.rb @@ -204,7 +204,7 @@ def validate_zone_list(attr) raise Puppet::Error, "parameter #{attr} must be an array of strings!" unless self[attr].is_a?(Array) - raise Puppet::Error, "parameter #{attr} must contain at least one zone!" if self[attr].length.zero? + raise Puppet::Error, "parameter #{attr} must contain at least one zone!" if self[attr].empty? self[attr].each do |element| case element diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 57b81911..3783594f 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -260,7 +260,7 @@ it do is_expected.to contain_exec('firewalld::set_log_denied').with( command: "firewall-cmd --set-log-denied #{cond} || firewall-offline-cmd --set-log-denied #{cond}", - unless: "[ \$\(firewall-cmd --get-log-denied || firewall-offline-cmd --get-log-denied) = #{cond} ]" + unless: "[ $(firewall-cmd --get-log-denied || firewall-offline-cmd --get-log-denied) = #{cond} ]" ).that_requires('Service[firewalld]') end end diff --git a/spec/unit/puppet/provider/firewalld_custom_service_spec.rb b/spec/unit/puppet/provider/firewalld_custom_service_spec.rb index 98576d95..cbd389d8 100644 --- a/spec/unit/puppet/provider/firewalld_custom_service_spec.rb +++ b/spec/unit/puppet/provider/firewalld_custom_service_spec.rb @@ -55,13 +55,13 @@ provider.expects(:execute_firewall_cmd).with(['--get-services'], nil).returns("#{resource[:name]} foo bar baz") provider.expects(:execute_firewall_cmd).with(['--path-service', resource[:name]], nil).returns('/etc/foo_bar_baz.xml') - expect(provider.exists?).to eq true + expect(provider.exists?).to be true end it 'does not exist when not returned by the system' do provider.expects(:execute_firewall_cmd).with(['--get-services'], nil).returns('foo bar baz') - expect(provider.exists?).to eq false + expect(provider.exists?).to be false end end diff --git a/spec/unit/puppet/type/firewalld_policy_spec.rb b/spec/unit/puppet/type/firewalld_policy_spec.rb index 56a1f461..8fb7cddd 100644 --- a/spec/unit/puppet/type/firewalld_policy_spec.rb +++ b/spec/unit/puppet/type/firewalld_policy_spec.rb @@ -78,8 +78,8 @@ described_class.new(name: 'bad ingress_zones', ingress_zones: [symbolic_zone, 'public'], egress_zones: ['restricted']) - end.to raise_error(%r{parameter ingress_zones must contain a single symbolic zone or one or more regular zones}) - end + end + end.to raise_error(%r{parameter ingress_zones must contain a single symbolic zone or one or more regular zones}) end it 'rejects bad egress_zones combinations' do @@ -88,8 +88,8 @@ described_class.new(name: 'bad egress_zones', ingress_zones: ['public'], egress_zones: [symbolic_zone, 'restricted']) - end.to raise_error(%r{parameter egress_zones must contain a single symbolic zone or one or more regular zones}) - end + end + end.to raise_error(%r{parameter egress_zones must contain a single symbolic zone or one or more regular zones}) end it 'accepts lone symbolic ingress_zones' do