Skip to content

Commit b141749

Browse files
author
jordanbreen28
committed
(CONT-792) - Correct Style/IfUnlessModifier
1 parent f87c000 commit b141749

File tree

10 files changed

+9
-40
lines changed

10 files changed

+9
-40
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,6 @@ Style/ClassAndModuleChildren:
160160
Exclude:
161161
- 'lib/puppet/util/postgresql_validator.rb'
162162

163-
# Offense count: 9
164-
# This cop supports safe autocorrection (--autocorrect).
165-
Style/IfUnlessModifier:
166-
Exclude:
167-
- 'lib/puppet/functions/postgresql/postgresql_acls_to_resources_hash.rb'
168-
- 'lib/puppet/functions/postgresql/postgresql_password.rb'
169-
- 'lib/puppet/provider/postgresql_psql/ruby.rb'
170-
- 'lib/puppet/provider/postgresql_replication_slot/ruby.rb'
171-
- 'lib/puppet/type/postgresql_psql.rb'
172-
- 'spec/acceptance/server/grant_role_spec.rb'
173-
- 'spec/acceptance/server/grant_spec.rb'
174-
- 'spec/acceptance/server/schema_spec.rb'
175-
- 'spec/acceptance/z_alternative_pgdata_spec.rb'
176163

177164
# Offense count: 2
178165
Style/MixinUsage:

lib/puppet/functions/postgresql/postgresql_acls_to_resources_hash.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ def default_impl(acls, id, offset)
3838
}
3939
if parts[0] == 'local'
4040
resource['auth_method'] = parts[3]
41-
if parts.length > 4
42-
resource['auth_option'] = parts.last(parts.length - 4).join(' ')
43-
end
41+
resource['auth_option'] = parts.last(parts.length - 4).join(' ') if parts.length > 4
4442
elsif %r{^\d}.match?(parts[4])
4543
resource['address'] = parts[3] + ' ' + parts[4]
4644
resource['auth_method'] = parts[5]

lib/puppet/functions/postgresql/postgresql_password.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
end
2929

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

3533
password = password.unwrap if password.respond_to?(:unwrap)
3634
pass = if hash == 'md5'

lib/puppet/provider/postgresql_psql/ruby.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ def run_unless_sql_command(sql)
99
end
1010

1111
def run_sql_command(sql)
12-
if resource[:search_path]
13-
sql = "set search_path to #{Array(resource[:search_path]).join(',')}; #{sql}"
14-
end
12+
sql = "set search_path to #{Array(resource[:search_path]).join(',')}; #{sql}" if resource[:search_path]
1513

1614
command = [resource[:psql_path]]
1715
command.push('-d', resource[:db]) if resource[:db]

lib/puppet/provider/postgresql_replication_slot/ruby.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ def self.instances
1515
def self.prefetch(resources)
1616
instances.each do |i|
1717
slot = resources[i.name]
18-
if slot
19-
slot.provider = i
20-
end
18+
slot.provider = i if slot
2119
end
2220
end
2321

lib/puppet/type/postgresql_psql.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ def matches(value)
110110

111111
validate do |values|
112112
Array(values).each do |value|
113-
unless %r{\w+=}.match?(value)
114-
raise ArgumentError, "Invalid environment setting '#{value}'"
115-
end
113+
raise ArgumentError, "Invalid environment setting '#{value}'" unless %r{\w+=}.match?(value)
116114
end
117115
end
118116
end

spec/acceptance/server/grant_role_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
let(:group) { 'test_group' }
99
let(:password) { 'psql_grant_role_pw' }
1010
let(:version) do
11-
if os[:family] == 'redhat' && os[:release].start_with?('5')
12-
'8.1'
13-
end
11+
'8.1' if os[:family] == 'redhat' && os[:release].start_with?('5')
1412
end
1513
let(:pp_one) do
1614
<<-MANIFEST.unindent

spec/acceptance/server/grant_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ class { 'postgresql::server': }
7979
end
8080

8181
it 'is expected to run idempotently' do
82-
if Gem::Version.new(postgresql_version) >= Gem::Version.new('8.4.0')
83-
idempotent_apply(pp)
84-
end
82+
idempotent_apply(pp) if Gem::Version.new(postgresql_version) >= Gem::Version.new('8.4.0')
8583
end
8684

8785
it 'is expected to GRANT USAGE ON LANGUAGE plpgsql to ROLE' do

spec/acceptance/server/schema_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
describe 'postgresql::server::schema:' do
66
let(:version) do
7-
if os[:family] == 'redhat' && os[:release].start_with?('5')
8-
'8.1'
9-
end
7+
'8.1' if os[:family] == 'redhat' && os[:release].start_with?('5')
108
end
119
let(:pp) do
1210
<<-MANIFEST.unindent

spec/acceptance/z_alternative_pgdata_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

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

1513
it 'on an alternative pgdata location' do

0 commit comments

Comments
 (0)