Skip to content

Commit 838625b

Browse files
committed
Addressing rubocop errors
1 parent fbb0a0f commit 838625b

File tree

299 files changed

+927
-938
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

299 files changed

+927
-938
lines changed

lib/facter/facter_dot_d.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def initialize(dir = '/etc/facts.d', cache_file = File.join(Puppet[:libdir], 'fa
2323

2424
def entries
2525
Dir.entries(@dir).reject { |f| f =~ %r{^\.|\.ttl$} }.sort.map { |f| File.join(@dir, f) }
26-
rescue
26+
rescue # rubocop:disable Lint/RescueWithoutErrorClass
2727
[]
2828
end
2929

@@ -113,14 +113,14 @@ def script_parser(file)
113113
def cache_save!
114114
cache = load_cache
115115
File.open(@cache_file, 'w', 0o600) { |f| f.write(YAML.dump(cache)) }
116-
rescue # rubocop:disable Lint/HandleExceptions - Is meant to be suppressed
116+
rescue # rubocop:disable Lint/HandleExceptions, Lint/RescueWithoutErrorClass
117117
end
118118

119119
def cache_store(file, data)
120120
load_cache
121121

122122
@cache[file] = { :data => data, :stored => Time.now.to_i }
123-
rescue # rubocop:disable Lint/HandleExceptions - Is meant to be suppressed
123+
rescue # rubocop:disable Lint/HandleExceptions, Lint/RescueWithoutErrorClass
124124
end
125125

126126
def cache_lookup(file)
@@ -136,29 +136,27 @@ def cache_lookup(file)
136136
return cache[file][:data] if ttl == -1
137137
return cache[file][:data] if (now - cache[file][:stored]) <= ttl
138138
return nil
139-
rescue
139+
rescue # rubocop:disable Lint/RescueWithoutErrorClass
140140
return nil
141141
end
142142

143143
def cache_time(file)
144144
meta = file + '.ttl'
145145

146146
return File.read(meta).chomp.to_i
147-
rescue
147+
rescue # rubocop:disable Lint/RescueWithoutErrorClass
148148
return 0
149149
end
150150

151151
def load_cache
152-
unless @cache
153-
@cache = if File.exist?(@cache_file)
152+
@cache ||= if File.exist?(@cache_file)
154153
YAML.load_file(@cache_file)
155154
else
156155
{}
157156
end
158-
end
159157

160158
return @cache
161-
rescue
159+
rescue # rubocop:disable Lint/RescueWithoutErrorClass
162160
@cache = {}
163161
return @cache
164162
end

lib/puppet/parser/functions/abs.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# abs.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:abs, :type => :rvalue, :doc => <<-EOS
5+
newfunction(:abs, :type => :rvalue, :doc => <<-DOC
66
Returns the absolute value of a number, for example -34.56 becomes
77
34.56. Takes a single integer and float value as an argument.
8-
EOS
8+
DOC
99
) do |arguments|
1010

1111
raise(Puppet::ParseError, "abs(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?

lib/puppet/parser/functions/any2array.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# any2array.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:any2array, :type => :rvalue, :doc => <<-EOS
5+
newfunction(:any2array, :type => :rvalue, :doc => <<-DOC
66
This converts any object to an array containing that object. Empty argument
77
lists are converted to an empty array. Arrays are left untouched. Hashes are
88
converted to arrays of alternating keys and values.
9-
EOS
9+
DOC
1010
) do |arguments|
1111

1212
if arguments.empty?

lib/puppet/parser/functions/any2bool.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# any2bool.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:any2bool, :type => :rvalue, :doc => <<-EOS
5+
newfunction(:any2bool, :type => :rvalue, :doc => <<-DOC
66
This converts 'anything' to a boolean. In practise it does the following:
77
88
* Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true
@@ -11,7 +11,7 @@ module Puppet::Parser::Functions
1111
* Number (or a string representation of a number) > 0 will return true, otherwise false
1212
* undef will return false
1313
* Anything else will return true
14-
EOS
14+
DOC
1515
) do |arguments|
1616

1717
raise(Puppet::ParseError, "any2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
@@ -33,7 +33,7 @@ module Puppet::Parser::Functions
3333

3434
valid_float = begin
3535
!!Float(arg) # rubocop:disable Style/DoubleNegation : Could not find a better way to check if a boolean
36-
rescue
36+
rescue # rubocop:disable Lint/RescueWithoutErrorClass
3737
false
3838
end
3939

lib/puppet/parser/functions/assert_private.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# assert_private.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:assert_private, :doc => <<-'EOS'
5+
newfunction(:assert_private, :doc => <<-DOC
66
Sets the current class or definition as private.
77
Calling the class or definition from outside the current module will fail.
8-
EOS
8+
DOC
99
) do |args|
1010

1111
raise(Puppet::ParseError, "assert_private(): Wrong number of arguments given (#{args.size}}) for 0 or 1)") if args.size > 1

lib/puppet/parser/functions/base64.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
22
module Puppet::Parser::Functions
3-
newfunction(:base64, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
3+
newfunction(:base64, :type => :rvalue, :doc => <<-'DOC') do |args|
44
Base64 encode or decode a string based on the command and the string submitted
55
66
Usage:
@@ -13,7 +13,7 @@ module Puppet::Parser::Functions
1313
$encodestring = base64('encode', 'thestring', $method)
1414
$decodestring = base64('decode', 'dGhlc3RyaW5n', $method)
1515
16-
ENDHEREDOC
16+
DOC
1717

1818
require 'base64'
1919

lib/puppet/parser/functions/basename.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# basename.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:basename, :type => :rvalue, :doc => <<-EOS
5+
newfunction(:basename, :type => :rvalue, :doc => <<-DOC
66
Strips directory (and optional suffix) from a filename
7-
EOS
7+
DOC
88
) do |arguments|
99

1010
raise(Puppet::ParseError, 'basename(): No arguments given') if arguments.empty?

lib/puppet/parser/functions/bool2num.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# bool2num.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS
5+
newfunction(:bool2num, :type => :rvalue, :doc => <<-DOC
66
Converts a boolean to a number. Converts the values:
77
false, f, 0, n, and no to 0
88
true, t, 1, y, and yes to 1
99
Requires a single boolean or string as an input.
10-
EOS
10+
DOC
1111
) do |arguments|
1212

1313
raise(Puppet::ParseError, "bool2num(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?

lib/puppet/parser/functions/bool2str.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# bool2str.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:bool2str, :type => :rvalue, :doc => <<-EOS
5+
newfunction(:bool2str, :type => :rvalue, :doc => <<-DOC
66
Converts a boolean to a string using optionally supplied arguments. The
77
optional second and third arguments represent what true and false will be
88
converted to respectively. If only one argument is given, it will be
@@ -15,7 +15,7 @@ module Puppet::Parser::Functions
1515
bool2str(false, 't', 'f') => 'f'
1616
1717
Requires a single boolean as an input.
18-
EOS
18+
DOC
1919
) do |arguments|
2020

2121
unless arguments.size == 1 || arguments.size == 3

lib/puppet/parser/functions/camelcase.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
44
#
55
module Puppet::Parser::Functions
6-
newfunction(:camelcase, :type => :rvalue, :doc => <<-EOS
6+
newfunction(:camelcase, :type => :rvalue, :doc => <<-DOC
77
Converts the case of a string or all strings in an array to camel case.
8-
EOS
8+
DOC
99
) do |arguments|
1010

1111
raise(Puppet::ParseError, "camelcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?

lib/puppet/parser/functions/capitalize.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
44
#
55
module Puppet::Parser::Functions
6-
newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS
6+
newfunction(:capitalize, :type => :rvalue, :doc => <<-DOC
77
Capitalizes the first letter of a string or array of strings.
88
Requires either a single string or an array as an input.
9-
EOS
9+
DOC
1010
) do |arguments|
1111

1212
raise(Puppet::ParseError, "capitalize(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?

lib/puppet/parser/functions/ceiling.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# ceiling.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:ceiling, :type => :rvalue, :doc => <<-EOS
5+
newfunction(:ceiling, :type => :rvalue, :doc => <<-DOC
66
Returns the smallest integer greater or equal to the argument.
77
Takes a single numeric value as an argument.
8-
EOS
8+
DOC
99
) do |arguments|
1010

1111
raise(Puppet::ParseError, "ceiling(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1

lib/puppet/parser/functions/chomp.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# chomp.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS'
5+
newfunction(:chomp, :type => :rvalue, :doc => <<-DOC
66
Removes the record separator from the end of a string or an array of
77
strings, for example `hello\n` becomes `hello`.
88
Requires a single string or array as an input.
9-
EOS
9+
DOC
1010
) do |arguments|
1111

1212
raise(Puppet::ParseError, "chomp(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?

lib/puppet/parser/functions/chop.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# chop.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:chop, :type => :rvalue, :doc => <<-'EOS'
5+
newfunction(:chop, :type => :rvalue, :doc => <<-DOC
66
Returns a new string with the last character removed. If the string ends
77
with `\r\n`, both characters are removed. Applying chop to an empty
88
string returns an empty string. If you wish to merely remove record
99
separators then you should use the `chomp` function.
1010
Requires a string or array of strings as input.
11-
EOS
11+
DOC
1212
) do |arguments|
1313

1414
raise(Puppet::ParseError, "chop(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?

lib/puppet/parser/functions/clamp.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# clamp.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-EOS
5+
newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-DOC
66
Clamps value to a range.
7-
EOS
7+
DOC
88
) do |args|
99

1010
args.flatten!

lib/puppet/parser/functions/concat.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# concat.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:concat, :type => :rvalue, :doc => <<-EOS
5+
newfunction(:concat, :type => :rvalue, :doc => <<-DOC
66
Appends the contents of multiple arrays into array 1.
77
88
*Example:*
@@ -12,7 +12,7 @@ module Puppet::Parser::Functions
1212
Would result in:
1313
1414
['1','2','3','4','5','6','7','8','9']
15-
EOS
15+
DOC
1616
) do |arguments|
1717

1818
# Check that more than 2 arguments have been given ...

lib/puppet/parser/functions/convert_base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# convert_base.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'ENDHEREDOC') do |args|
5+
newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'DOC') do |args|
66
Converts a given integer or base 10 string representing an integer to a specified base, as a string.
77
88
Usage:
99
1010
$binary_repr = convert_base(5, 2) # $binary_repr is now set to "101"
1111
$hex_repr = convert_base("254", "16") # $hex_repr is now set to "fe"
1212
13-
ENDHEREDOC
13+
DOC
1414

1515
raise Puppet::ParseError, 'convert_base(): First argument must be either a string or an integer' unless args[0].is_a?(Integer) || args[0].is_a?(String)
1616
raise Puppet::ParseError, 'convert_base(): Second argument must be either a string or an integer' unless args[1].is_a?(Integer) || args[1].is_a?(String)

lib/puppet/parser/functions/count.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# count.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-EOS
5+
newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-DOC
66
Takes an array as first argument and an optional second argument.
77
Count the number of elements in array that matches second argument.
88
If called with only an array it counts the number of elements that are not nil/undef.
9-
EOS
9+
DOC
1010
) do |args|
1111

1212
if args.size > 2

lib/puppet/parser/functions/deep_merge.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# deep_merge.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:deep_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
5+
newfunction(:deep_merge, :type => :rvalue, :doc => <<-'DOC') do |args|
66
Recursively merges two or more hashes together and returns the resulting hash.
77
88
For example:
@@ -16,7 +16,7 @@ module Puppet::Parser::Functions
1616
When there is a duplicate key that is a hash, they are recursively merged.
1717
When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
1818
19-
ENDHEREDOC
19+
DOC
2020

2121
if args.length < 2
2222
raise Puppet::ParseError, "deep_merge(): wrong number of arguments (#{args.length}; must be at least 2)"

lib/puppet/parser/functions/defined_with_params.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
Puppet::Parser::Functions.newfunction(:defined_with_params,
55
:type => :rvalue,
6-
:doc => <<-'ENDOFDOC'
6+
:doc => <<-'DOC'
77
Takes a resource reference and an optional hash of attributes.
88
99
Returns true if a resource with the specified attributes has already been added
@@ -16,7 +16,7 @@
1616
if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
1717
user { 'dan': ensure => present, }
1818
}
19-
ENDOFDOC
19+
DOC
2020
) do |vals|
2121
reference, params = vals
2222
raise(ArgumentError, 'Must specify a reference') unless reference

lib/puppet/parser/functions/delete.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# delete.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:delete, :type => :rvalue, :doc => <<-EOS
5+
newfunction(:delete, :type => :rvalue, :doc => <<-DOC
66
Deletes all instances of a given element from an array, substring from a
77
string, or key from a hash.
88
@@ -19,7 +19,7 @@ module Puppet::Parser::Functions
1919
2020
delete('abracadabra', 'bra')
2121
Would return: 'acada'
22-
EOS
22+
DOC
2323
) do |arguments|
2424

2525
raise(Puppet::ParseError, "delete(): Wrong number of arguments given #{arguments.size} for 2") unless arguments.size == 2

lib/puppet/parser/functions/delete_at.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# delete_at.rb
33
#
44
module Puppet::Parser::Functions
5-
newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS
5+
newfunction(:delete_at, :type => :rvalue, :doc => <<-DOC
66
Deletes a determined indexed value from an array.
77
88
*Examples:*
99
1010
delete_at(['a','b','c'], 1)
1111
1212
Would return: ['a','c']
13-
EOS
13+
DOC
1414
) do |arguments|
1515

1616
raise(Puppet::ParseError, "delete_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2

0 commit comments

Comments
 (0)