Skip to content

Commit

Permalink
[style] updates for puppet-lint and rubocop failures
Browse files Browse the repository at this point in the history
modulesync 3.0 updates some style guidelines
  • Loading branch information
wyardley committed Jul 29, 2020
1 parent e56c258 commit 86e2345
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 56 deletions.
2 changes: 1 addition & 1 deletion examples/erlang_deps.pp
@@ -1,5 +1,5 @@
# install first the garethr-erlang module. See README.md
include erlang

class { 'erlang': epel_enable => true}
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
2 changes: 1 addition & 1 deletion examples/plugin.pp
@@ -1,4 +1,4 @@
$rabbitmq_plugins = [ 'amqp_client', 'rabbitmq_stomp' ]
$rabbitmq_plugins = ['amqp_client', 'rabbitmq_stomp']

class { 'rabbitmq':
config_stomp => true,
Expand Down
4 changes: 1 addition & 3 deletions examples/site.pp
@@ -1,6 +1,5 @@
node default {

$rabbitmq_plugins = [ 'amqp_client', 'rabbitmq_stomp' ]
$rabbitmq_plugins = ['amqp_client', 'rabbitmq_stomp']

class { 'rabbitmq':
config => '[ {rabbit_stomp, [{tcp_listeners, [1234]} ]} ].',
Expand All @@ -13,4 +12,3 @@
provider => 'rabbitmqplugins',
}
}

11 changes: 5 additions & 6 deletions manifests/config.pp
Expand Up @@ -3,7 +3,6 @@
#
# @api private
class rabbitmq::config {

$admin_enable = $rabbitmq::admin_enable
$management_enable = $rabbitmq::management_enable
$use_config_file_for_plugins = $rabbitmq::use_config_file_for_plugins
Expand Down Expand Up @@ -104,7 +103,7 @@
$management_ip_address = $rabbitmq::node_ip_address
}

$inetrc_env = {'export ERL_INETRC' => $inetrc_config_path}
$inetrc_env = { 'export ERL_INETRC' => $inetrc_config_path }

# Handle env variables.
$_environment_variables = $default_ssl_env_variables + $inetrc_env + $rabbitmq::environment_variables
Expand All @@ -125,7 +124,7 @@
$proto_dist = 'inet6_tcp'
$ssl_path = ''
}
$ipv6_or_tls_env = ['SERVER_ADDITIONAL', 'CTL'].reduce({}) |$memo, $item| {
$ipv6_or_tls_env = ['SERVER_ADDITIONAL', 'CTL'].reduce( {}) |$memo, $item| {
$orig = $_environment_variables["RABBITMQ_${item}_ERL_ARGS"]
$munged = $orig ? {
# already quoted, keep quoting
Expand All @@ -136,7 +135,7 @@
default => "\"${orig}${ssl_path} -proto_dist ${proto_dist}\"",
}
merge($memo, {"RABBITMQ_${item}_ERL_ARGS" => $munged})
merge($memo, { "RABBITMQ_${item}_ERL_ARGS" => $munged })
}
$environment_variables = $_environment_variables + $ipv6_or_tls_env
Expand Down Expand Up @@ -227,12 +226,12 @@
mode => '0644',
}
}
default: { }
default: {}
}
if $facts['systemd'] { # systemd fact provided by systemd module
systemd::service_limits { "${service_name}.service":
limits => {'LimitNOFILE' => $file_limit},
limits => { 'LimitNOFILE' => $file_limit },
# The service will be notified when config changes
restart_service => false,
}
Expand Down
6 changes: 2 additions & 4 deletions manifests/init.pp
Expand Up @@ -298,7 +298,7 @@
# @param loopback_users
# This option configures a list of users to allow access via the loopback interfaces
#
class rabbitmq(
class rabbitmq (
Boolean $admin_enable = true,
Boolean $management_enable = false,
Boolean $use_config_file_for_plugins = false,
Expand Down Expand Up @@ -399,12 +399,11 @@
Array $loopback_users = ['guest'],
Boolean $service_restart = true,
) {

if $ssl_only and ! $ssl {
fail('$ssl_only => true requires that $ssl => true')
}

if $config_stomp and $stomp_ssl_only and ! $ssl_stomp_port {
if $config_stomp and $stomp_ssl_only and ! $ssl_stomp_port {
fail('$stomp_ssl_only requires that $ssl_stomp_port be set')
}

Expand Down Expand Up @@ -498,5 +497,4 @@

# Make sure the various providers have their requirements in place.
Class['rabbitmq::install'] -> Rabbitmq_plugin<| |>

}
1 change: 0 additions & 1 deletion manifests/install.pp
Expand Up @@ -2,7 +2,6 @@
#
# @api private
class rabbitmq::install {

$package_ensure = $rabbitmq::package_ensure
$package_name = $rabbitmq::package_name
$rabbitmq_group = $rabbitmq::rabbitmq_group
Expand Down
4 changes: 1 addition & 3 deletions manifests/install/rabbitmqadmin.pp
Expand Up @@ -2,14 +2,12 @@
#
# @api private
class rabbitmq::install::rabbitmqadmin {

if $rabbitmq::rabbitmqadmin_package {
package{'rabbitmqadmin':
package { 'rabbitmqadmin':
ensure => 'present',
name => $rabbitmq::rabbitmqadmin_package,
}
} else {

$python_package = $rabbitmq::python_package
# Some systems (e.g., Ubuntu 16.04) don't ship Python 2 by default
if $rabbitmq::manage_python {
Expand Down
4 changes: 1 addition & 3 deletions manifests/management.pp
Expand Up @@ -2,14 +2,12 @@
#
# @api private
class rabbitmq::management {

$delete_guest_user = $rabbitmq::delete_guest_user

if $delete_guest_user {
rabbitmq_user{ 'guest':
rabbitmq_user { 'guest':
ensure => absent,
provider => 'rabbitmqctl',
}
}

}
5 changes: 2 additions & 3 deletions manifests/repo/apt.pp
Expand Up @@ -3,16 +3,15 @@
# puppetlabs-stdlib
#
# @api private
class rabbitmq::repo::apt(
class rabbitmq::repo::apt (
String $location = 'https://packagecloud.io/rabbitmq/rabbitmq-server',
String $repos = 'main',
Boolean $include_src = false,
String $key = '8C695B0219AFDEB04A058ED8F4E789204D206F89',
String $key_source = $rabbitmq::package_gpg_key,
Optional[String] $key_content = $rabbitmq::key_content,
Optional[String] $architecture = undef,
) {

) {
$osname = downcase($facts['os']['name'])
$pin = $rabbitmq::package_apt_pin

Expand Down
9 changes: 4 additions & 5 deletions manifests/repo/rhel.pp
@@ -1,11 +1,10 @@
# Makes sure that the Packagecloud repo is installed
#
# @api private
class rabbitmq::repo::rhel(
$location = "https://packagecloud.io/rabbitmq/rabbitmq-server/el/${facts['os'][release][major]}/\$basearch",
String $key_source = $rabbitmq::package_gpg_key,
) {

class rabbitmq::repo::rhel (
$location = "https://packagecloud.io/rabbitmq/rabbitmq-server/el/${facts['os'][release][major]}/\$basearch",
String $key_source = $rabbitmq::package_gpg_key,
) {
yumrepo { 'rabbitmq':
ensure => present,
name => 'rabbitmq_rabbitmq-server',
Expand Down
4 changes: 1 addition & 3 deletions manifests/service.pp
@@ -1,12 +1,11 @@
# This class manages the rabbitmq server service itself.
#
# @api private
class rabbitmq::service(
class rabbitmq::service (
Enum['running', 'stopped'] $service_ensure = $rabbitmq::service_ensure,
Boolean $service_manage = $rabbitmq::service_manage,
$service_name = $rabbitmq::service_name,
) inherits rabbitmq {

if ($service_manage) {
if $service_ensure == 'running' {
$ensure_real = 'running'
Expand All @@ -28,5 +27,4 @@
Class['systemd::systemctl::daemon_reload'] -> Service['rabbitmq-server']
}
}

}
2 changes: 0 additions & 2 deletions spec/acceptance/parameter_spec.rb
Expand Up @@ -35,8 +35,6 @@ class { 'rabbitmq':
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

# rubocop:disable RSpec/MultipleExpectations
it 'has the parameter' do
shell('rabbitmqctl list_parameters -p fedhost') do |r|
expect(r.stdout).to match(%r{federation-upstream.*documentumFed.*expires.*3600000})
Expand Down
2 changes: 0 additions & 2 deletions spec/acceptance/policy_spec.rb
Expand Up @@ -46,8 +46,6 @@ class { 'rabbitmq':
apply_manifest(pp, catch_failures: true)
expect(apply_manifest(pp, catch_changes: true).exit_code).to be_zero
end

# rubocop:disable RSpec/MultipleExpectations
it 'has the policy' do
shell('rabbitmqctl list_policies -p myhost') do |r|
expect(r.stdout).to match(%r{myhost.*ha-all.*ha-sync-mode})
Expand Down
6 changes: 0 additions & 6 deletions spec/acceptance/queue_spec.rb
Expand Up @@ -59,8 +59,6 @@ class { 'rabbitmq':
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

# rubocop:disable RSpec/MultipleExpectations
it 'has the binding' do
shell('rabbitmqctl list_bindings -q -p host1') do |r|
expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\s#})
Expand Down Expand Up @@ -149,8 +147,6 @@ class { 'rabbitmq':
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

# rubocop:disable RSpec/MultipleExpectations
it 'has the bindings' do
shell('rabbitmqctl list_bindings -q -p host1') do |r|
expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\stest1})
Expand Down Expand Up @@ -226,8 +222,6 @@ class { 'rabbitmq':
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

# rubocop:disable RSpec/MultipleExpectations
it 'has the binding' do
shell('rabbitmqctl list_bindings -q -p host2') do |r|
expect(r.stdout).to match(%r{exchange2\sexchange\squeue2\squeue\s#})
Expand Down
2 changes: 0 additions & 2 deletions spec/acceptance/user_spec.rb
Expand Up @@ -24,8 +24,6 @@ class { 'rabbitmq':
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

# rubocop:disable RSpec/MultipleExpectations
it 'has the user' do
shell('rabbitmqctl list_users -q') do |r|
expect(r.stdout).to match(%r{dan.*administrator})
Expand Down
2 changes: 0 additions & 2 deletions spec/acceptance/vhost_spec.rb
Expand Up @@ -23,8 +23,6 @@ class { 'rabbitmq':
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

# rubocop:disable RSpec/MultipleExpectations
it 'has the vhost' do
shell('rabbitmqctl list_vhosts') do |r|
expect(r.stdout).to match(%r{myhost})
Expand Down
Expand Up @@ -11,8 +11,6 @@
)
end
let(:provider) { provider_class.new(resource) }

# rubocop:disable RSpec/MultipleExpectations
describe '#instances' do
it 'returns instances' do
provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT
Expand Down Expand Up @@ -42,8 +40,6 @@
])
end
# rubocop:enable RSpec/MultipleExpectations

# rubocop:disable RSpec/MultipleExpectations
it 'returns multiple instances' do
provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT
/
Expand Down
Expand Up @@ -57,8 +57,6 @@
instances = provider_class.instances
expect(instances.size).to eq(0)
end

# rubocop:disable RSpec/MultipleExpectations
it 'return one instance' do
provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT
/
Expand Down Expand Up @@ -90,8 +88,6 @@
)
end
# rubocop:enable RSpec/MultipleExpectations

# rubocop:disable RSpec/MultipleExpectations
it 'return multiple instances' do
provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT
/
Expand Down
1 change: 0 additions & 1 deletion spec/unit/puppet/type/rabbitmq_user_permissions_spec.rb
Expand Up @@ -36,7 +36,6 @@
end.to raise_error(Puppet::Error, %r{Invalid regexp})
end
end
# rubocop:disable RSpec/MultipleExpectations
{ rabbitmq_vhost: 'dan@test', rabbitmq_user: 'test@dan' }.each do |k, v|
it "should autorequire #{k}" do
vhost = if k == :rabbitmq_vhost
Expand Down

0 comments on commit 86e2345

Please sign in to comment.