Skip to content

Commit ef26708

Browse files
author
willmeek
authored
Merge pull request #863 from pmcmaw/rubocop_error
(FM-6634) - Addressing rubocop errors
2 parents 7ca406c + 21e7ce8 commit ef26708

File tree

298 files changed

+925
-936
lines changed

Some content is hidden

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

298 files changed

+925
-936
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?

0 commit comments

Comments
 (0)