Skip to content

Commit c6287f0

Browse files
committed
Workaround for heredocs in puppet-strings
puppet-strings choke on heredoc start tags followed by a comma. Because rubocop ensures a comma is present after the last parameter of a multiline method call, change these calls to in-line calls so that we do not cause issue with puppet-strings nor with rubocop.
1 parent 75eb48f commit c6287f0

File tree

10 files changed

+14
-45
lines changed

10 files changed

+14
-45
lines changed

lib/puppet/parser/functions/defined_with_params.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
# Test whether a given class or definition is defined
44
require 'puppet/parser/functions'
55

6-
Puppet::Parser::Functions.newfunction(:defined_with_params,
7-
type: :rvalue,
8-
doc: <<-DOC
6+
Puppet::Parser::Functions.newfunction(:defined_with_params, type: :rvalue, doc: <<-DOC
97
@summary
108
Takes a resource reference and an optional hash of attributes.
119
@@ -25,7 +23,7 @@
2523
@return [Boolean]
2624
returns `true` or `false`
2725
DOC
28-
) do |vals|
26+
) do |vals|
2927
reference, params = vals
3028
raise(ArgumentError, 'Must specify a reference') unless reference
3129
if !params || params == ''

lib/puppet/parser/functions/dig44.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
# dig44.rb
55
#
66
module Puppet::Parser::Functions
7-
newfunction(
8-
:dig44,
9-
type: :rvalue,
10-
arity: -2,
11-
doc: <<-DOC
7+
newfunction(:dig44, type: :rvalue, arity: -2, doc: <<-DOC
128
@summary
139
**DEPRECATED**: Looks up into a complex structure of arrays and hashes and returns a value
1410
or the default value if nothing was found.

lib/puppet/parser/functions/ensure_resource.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
# Test whether a given class or definition is defined
44
require 'puppet/parser/functions'
55

6-
Puppet::Parser::Functions.newfunction(:ensure_resource,
7-
type: :statement,
8-
doc: <<-DOC
6+
Puppet::Parser::Functions.newfunction(:ensure_resource, type: :statement, doc: <<-DOC
97
@summary
108
Takes a resource type, title, and a list of attributes that describe a
119
resource.
@@ -33,7 +31,7 @@
3331
ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})
3432
3533
DOC
36-
) do |vals|
34+
) do |vals|
3735
type, title, params = vals
3836
raise(ArgumentError, 'Must specify a type') unless type
3937
raise(ArgumentError, 'Must specify a title') unless title

lib/puppet/parser/functions/ensure_resources.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
require 'puppet/parser/functions'
44

5-
Puppet::Parser::Functions.newfunction(:ensure_resources,
6-
type: :statement,
7-
doc: <<-DOC
5+
Puppet::Parser::Functions.newfunction(:ensure_resources, type: :statement, doc: <<-DOC
86
@summary
97
Takes a resource type, title (only hash), and a list of attributes that describe a
108
resource.
@@ -36,7 +34,7 @@
3634
Call:
3735
ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
3836
DOC
39-
) do |vals|
37+
) do |vals|
4038
type, title, params = vals
4139
raise(ArgumentError, 'Must specify a type') unless type
4240
raise(ArgumentError, 'Must specify a title') unless title

lib/puppet/parser/functions/fqdn_rand_string.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# frozen_string_literal: true
22

3-
Puppet::Parser::Functions.newfunction(
4-
:fqdn_rand_string,
5-
arity: -2,
6-
type: :rvalue,
7-
doc: <<-DOC
3+
Puppet::Parser::Functions.newfunction(:fqdn_rand_string, arity: -2, type: :rvalue, doc: <<-DOC
84
@summary
95
Generates a random alphanumeric string. Combining the `$fqdn` fact and an
106
optional seed for repeatable randomness.

lib/puppet/parser/functions/fqdn_rotate.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
#
44
# fqdn_rotate.rb
55
#
6-
Puppet::Parser::Functions.newfunction(
7-
:fqdn_rotate,
8-
type: :rvalue,
9-
doc: <<-DOC
6+
Puppet::Parser::Functions.newfunction(:fqdn_rotate, type: :rvalue, doc: <<-DOC
107
@summary
118
Rotates an array or string a random number of times, combining the `$fqdn` fact
129
and an optional seed for repeatable randomness.

lib/puppet/parser/functions/getparam.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
# Test whether a given class or definition is defined
44
require 'puppet/parser/functions'
55

6-
Puppet::Parser::Functions.newfunction(:getparam,
7-
type: :rvalue,
8-
doc: <<-'DOC'
6+
Puppet::Parser::Functions.newfunction(:getparam, type: :rvalue, doc: <<-'DOC'
97
@summary
108
Returns the value of a resource's parameter.
119
@@ -45,7 +43,7 @@
4543
```Example_resource['example_resource_instance']['param']``
4644
4745
DOC
48-
) do |vals|
46+
) do |vals|
4947
reference, param = vals
5048
raise(ArgumentError, 'Must specify a reference') unless reference
5149
raise(ArgumentError, 'Must specify name of a parameter') unless param&.instance_of?(String)

lib/puppet/parser/functions/pw_hash.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible.
44
# To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
55
#
6-
Puppet::Parser::Functions.newfunction(
7-
:pw_hash,
8-
type: :rvalue,
9-
arity: 3,
10-
doc: <<-DOC
6+
Puppet::Parser::Functions.newfunction(:pw_hash, type: :rvalue, arity: 3, doc: <<-DOC
117
@summary
128
Hashes a password using the crypt function. Provides a hash usable
139
on most POSIX systems.

lib/puppet/parser/functions/seeded_rand.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
#
44
# seeded_rand.rb
55
#
6-
Puppet::Parser::Functions.newfunction(
7-
:seeded_rand,
8-
arity: 2,
9-
type: :rvalue,
10-
doc: <<-DOC
6+
Puppet::Parser::Functions.newfunction(:seeded_rand, arity: 2, type: :rvalue, doc: <<-DOC
117
@summary
128
Generates a random whole number greater than or equal to 0 and less than MAX, using the value of SEED for repeatable randomness.
139

lib/puppet/parser/functions/try_get_value.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
# try_get_value.rb
55
#
66
module Puppet::Parser::Functions
7-
newfunction(
8-
:try_get_value,
9-
type: :rvalue,
10-
arity: -2,
11-
doc: <<-DOC
7+
newfunction(:try_get_value, type: :rvalue, arity: -2, doc: <<-DOC
128
@summary
139
**DEPRECATED:** this function is deprecated, please use dig() instead.
1410

0 commit comments

Comments
 (0)