Skip to content

Commit

Permalink
Run through Rubocop -A
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Riehecky committed Aug 24, 2023
1 parent 8efbc21 commit c63f039
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/firewalld_policy/firewall_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/firewalld_zone/firewall_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/firewalld_ipset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/type/firewalld_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
require 'tmpdir'
require 'yaml'
require 'simp/beaker_helpers'
# rubocop:disable Style/MixinUsage
include Simp::BeakerHelpers
# rubocop:enable Style/MixinUsage

UNSUPPORTED_PLATFORMS = %w[windows Darwin].freeze

Expand Down
4 changes: 2 additions & 2 deletions spec/unit/puppet/provider/firewalld_custom_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions spec/unit/puppet/type/firewalld_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c63f039

Please sign in to comment.