Skip to content

Commit

Permalink
(CONT-792) - Correct Style/IfUnlessModifier
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbreen28 committed Apr 19, 2023
1 parent f87c000 commit b141749
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 40 deletions.
13 changes: 0 additions & 13 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,6 @@ Style/ClassAndModuleChildren:
Exclude:
- 'lib/puppet/util/postgresql_validator.rb'

# Offense count: 9
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'lib/puppet/functions/postgresql/postgresql_acls_to_resources_hash.rb'
- 'lib/puppet/functions/postgresql/postgresql_password.rb'
- 'lib/puppet/provider/postgresql_psql/ruby.rb'
- 'lib/puppet/provider/postgresql_replication_slot/ruby.rb'
- 'lib/puppet/type/postgresql_psql.rb'
- 'spec/acceptance/server/grant_role_spec.rb'
- 'spec/acceptance/server/grant_spec.rb'
- 'spec/acceptance/server/schema_spec.rb'
- 'spec/acceptance/z_alternative_pgdata_spec.rb'

# Offense count: 2
Style/MixinUsage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def default_impl(acls, id, offset)
}
if parts[0] == 'local'
resource['auth_method'] = parts[3]
if parts.length > 4
resource['auth_option'] = parts.last(parts.length - 4).join(' ')
end
resource['auth_option'] = parts.last(parts.length - 4).join(' ') if parts.length > 4
elsif %r{^\d}.match?(parts[4])
resource['address'] = parts[3] + ' ' + parts[4]
resource['auth_method'] = parts[5]
Expand Down
4 changes: 1 addition & 3 deletions lib/puppet/functions/postgresql/postgresql_password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
end

def default_impl(username, password, sensitive = false, hash = 'md5', salt = nil)
if password.is_a?(String) && password.match?(%r{^(md5|SCRAM-SHA-256).+})
return password
end
return password if password.is_a?(String) && password.match?(%r{^(md5|SCRAM-SHA-256).+})

password = password.unwrap if password.respond_to?(:unwrap)
pass = if hash == 'md5'
Expand Down
4 changes: 1 addition & 3 deletions lib/puppet/provider/postgresql_psql/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ def run_unless_sql_command(sql)
end

def run_sql_command(sql)
if resource[:search_path]
sql = "set search_path to #{Array(resource[:search_path]).join(',')}; #{sql}"
end
sql = "set search_path to #{Array(resource[:search_path]).join(',')}; #{sql}" if resource[:search_path]

command = [resource[:psql_path]]
command.push('-d', resource[:db]) if resource[:db]
Expand Down
4 changes: 1 addition & 3 deletions lib/puppet/provider/postgresql_replication_slot/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ def self.instances
def self.prefetch(resources)
instances.each do |i|
slot = resources[i.name]
if slot
slot.provider = i
end
slot.provider = i if slot
end
end

Expand Down
4 changes: 1 addition & 3 deletions lib/puppet/type/postgresql_psql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ def matches(value)

validate do |values|
Array(values).each do |value|
unless %r{\w+=}.match?(value)
raise ArgumentError, "Invalid environment setting '#{value}'"
end
raise ArgumentError, "Invalid environment setting '#{value}'" unless %r{\w+=}.match?(value)
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions spec/acceptance/server/grant_role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
let(:group) { 'test_group' }
let(:password) { 'psql_grant_role_pw' }
let(:version) do
if os[:family] == 'redhat' && os[:release].start_with?('5')
'8.1'
end
'8.1' if os[:family] == 'redhat' && os[:release].start_with?('5')
end
let(:pp_one) do
<<-MANIFEST.unindent
Expand Down
4 changes: 1 addition & 3 deletions spec/acceptance/server/grant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ class { 'postgresql::server': }
end

it 'is expected to run idempotently' do
if Gem::Version.new(postgresql_version) >= Gem::Version.new('8.4.0')
idempotent_apply(pp)
end
idempotent_apply(pp) if Gem::Version.new(postgresql_version) >= Gem::Version.new('8.4.0')
end

it 'is expected to GRANT USAGE ON LANGUAGE plpgsql to ROLE' do
Expand Down
4 changes: 1 addition & 3 deletions spec/acceptance/server/schema_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

describe 'postgresql::server::schema:' do
let(:version) do
if os[:family] == 'redhat' && os[:release].start_with?('5')
'8.1'
end
'8.1' if os[:family] == 'redhat' && os[:release].start_with?('5')
end
let(:pp) do
<<-MANIFEST.unindent
Expand Down
4 changes: 1 addition & 3 deletions spec/acceptance/z_alternative_pgdata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

describe 'postgresql::server', skip: 'IAC-1286' do
before(:each) do
if os[:family] == 'sles'
skip "These test's currently do not work on SLES/Suse modules"
end
skip "These test's currently do not work on SLES/Suse modules" if os[:family] == 'sles'
end

it 'on an alternative pgdata location' do
Expand Down

0 comments on commit b141749

Please sign in to comment.