Skip to content

Commit

Permalink
(CONT-792) - Correct Style/RedundantRegexpEscape
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbreen28 committed Apr 19, 2023
1 parent 53c8642 commit 973e15b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 15 deletions.
8 changes: 0 additions & 8 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,6 @@ Style/OptionalBooleanParameter:
- 'lib/puppet/functions/postgresql/postgresql_password.rb'
- 'lib/puppet/type/postgresql_psql.rb'

# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpEscape:
Exclude:
- 'lib/puppet/provider/postgresql_conf/parsed.rb'
- 'lib/puppet/type/postgresql_conf.rb'
- 'spec/defines/server/pg_hba_rule_spec.rb'
- 'spec/spec_helper_acceptance_local.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/postgresql_conf/parsed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
record_line :parsed,
fields: ['name', 'value', 'comment'],
optional: ['comment'],
match: %r{^\s*([\w\.]+)\s*=?\s*(.*?)(?:\s*#\s*(.*))?\s*$},
match: %r{^\s*([\w.]+)\s*=?\s*(.*?)(?:\s*#\s*(.*))?\s*$},
to_line: proc { |h|
# simple string and numeric values don't need to be enclosed in quotes
val = if h[:value].is_a?(Numeric)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/type/postgresql_conf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
desc 'The postgresql parameter name to manage.'
isnamevar

newvalues(%r{^[\w\.]+$})
newvalues(%r{^[\w.]+$})
end

newproperty(:value) do
Expand Down
8 changes: 4 additions & 4 deletions spec/defines/server/pg_hba_rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class { 'postgresql::server': }
end

it do
expect(subject).to contain_concat__fragment('pg_hba_rule_test').with(content: %r{host\s+all\s+all\s+1\.1\.1\.1\/24\s+md5})
expect(subject).to contain_concat__fragment('pg_hba_rule_test').with(content: %r{host\s+all\s+all\s+1\.1\.1\.1/24\s+md5})
end
end

Expand Down Expand Up @@ -76,7 +76,7 @@ class { 'postgresql::server': }
end

it do
expect(subject).to contain_concat__fragment('pg_hba_rule_test').with(content: %r{host\s+all\s+all\s+0\.0\.0\.0\/0\s+ldap\s+foo=bar})
expect(subject).to contain_concat__fragment('pg_hba_rule_test').with(content: %r{host\s+all\s+all\s+0\.0\.0\.0/0\s+ldap\s+foo=bar})
end
end

Expand Down Expand Up @@ -104,7 +104,7 @@ class { 'postgresql::server': }

it do
expect(subject).to contain_concat__fragment('pg_hba_rule_test').with(
content: %r{local\s+all\s+all\s+0\.0\.0\.0\/0\s+peer},
content: %r{local\s+all\s+all\s+0\.0\.0\.0/0\s+peer},
)
end
end
Expand Down Expand Up @@ -132,7 +132,7 @@ class { 'postgresql::server': }

it do
expect(subject).to contain_concat__fragment('pg_hba_rule_test').with(
content: %r{local\s+all\s+all\s+0\.0\.0\.0\/0\s+scram-sha-256},
content: %r{local\s+all\s+all\s+0\.0\.0\.0/0\s+scram-sha-256},
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper_acceptance_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def shellescape(str)
# Treat multibyte characters as is. It is caller's responsibility
# to encode the string in the right encoding for the shell
# environment.
str.gsub!(%r{([^A-Za-z0-9_\-.,:\/@\n])}, '\\\\\\1')
str.gsub!(%r{([^A-Za-z0-9_\-.,:/@\n])}, '\\\\\\1')

# A LF cannot be escaped with a backslash because a backslash + LF
# combo is regarded as line continuation and simply ignored.
Expand Down

0 comments on commit 973e15b

Please sign in to comment.