Skip to content

Commit e2c3f6a

Browse files
committed
(CONT-801) Autocorrect safe group 7
1 parent 8215008 commit e2c3f6a

File tree

19 files changed

+32
-84
lines changed

19 files changed

+32
-84
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -290,58 +290,6 @@ Style/RedundantArgument:
290290
Exclude:
291291
- 'lib/puppet/provider/file_line/ruby.rb'
292292

293-
# Offense count: 1
294-
# This cop supports safe autocorrection (--autocorrect).
295-
Style/RedundantFileExtensionInRequire:
296-
Exclude:
297-
- 'lib/puppet/functions/to_toml.rb'
298-
299-
# Offense count: 6
300-
# This cop supports safe autocorrection (--autocorrect).
301-
Style/RedundantHeredocDelimiterQuotes:
302-
Exclude:
303-
- 'lib/puppet/parser/functions/convert_base.rb'
304-
- 'lib/puppet/parser/functions/deep_merge.rb'
305-
- 'lib/puppet/parser/functions/getparam.rb'
306-
- 'lib/puppet/parser/functions/loadjson.rb'
307-
- 'lib/puppet/parser/functions/loadyaml.rb'
308-
- 'lib/puppet/parser/functions/merge.rb'
309-
310-
# Offense count: 1
311-
# This cop supports safe autocorrection (--autocorrect).
312-
Style/RedundantParentheses:
313-
Exclude:
314-
- 'lib/puppet/parser/functions/pw_hash.rb'
315-
316-
# Offense count: 41
317-
# This cop supports safe autocorrection (--autocorrect).
318-
Style/RedundantRegexpEscape:
319-
Exclude:
320-
- 'lib/puppet/parser/functions/loadjson.rb'
321-
- 'lib/puppet/parser/functions/loadyaml.rb'
322-
- 'lib/puppet/parser/functions/range.rb'
323-
- 'lib/puppet/parser/functions/values_at.rb'
324-
- 'spec/functions/load_module_metadata_spec.rb'
325-
- 'spec/functions/loadjson_spec.rb'
326-
- 'spec/functions/validate_cmd_spec.rb'
327-
328-
# Offense count: 4
329-
# This cop supports safe autocorrection (--autocorrect).
330-
Style/RedundantStringEscape:
331-
Exclude:
332-
- 'lib/puppet/type/file_line.rb'
333-
334-
# Offense count: 4
335-
# This cop supports safe autocorrection (--autocorrect).
336-
# Configuration parameters: EnforcedStyle.
337-
# SupportedStyles: implicit, explicit
338-
Style/RescueStandardError:
339-
Exclude:
340-
- 'lib/puppet/functions/stdlib/crc32.rb'
341-
- 'lib/puppet/functions/stdlib/sha256.rb'
342-
- 'lib/puppet/parser/functions/any2bool.rb'
343-
- 'spec/spec_helper.rb'
344-
345293
# Offense count: 1
346294
# This cop supports unsafe autocorrection (--autocorrect-all).
347295
Style/SelectByRegexp:

lib/puppet/functions/stdlib/crc32.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
def crc32(my_data)
2727
Zlib.crc32(my_data.unwrap.to_s).to_s(16).downcase
28-
rescue
28+
rescue StandardError
2929
Zlib.crc32(my_data.to_s).to_s(16).downcase
3030
end
3131
end

lib/puppet/functions/stdlib/sha256.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
def sha256(my_data)
2222
Digest::SHA256.hexdigest(my_data.unwrap.to_s)
23-
rescue
23+
rescue StandardError
2424
Digest::SHA256.hexdigest(my_data.to_s)
2525
end
2626
end

lib/puppet/functions/to_toml.rb

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

3-
require_relative '../../puppet_x/stdlib/toml_dumper.rb'
3+
require_relative '../../puppet_x/stdlib/toml_dumper'
44

55
# @summary Convert a data structure and output to TOML.
66
Puppet::Functions.create_function(:to_toml) do

lib/puppet/parser/functions/any2bool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module Puppet::Parser::Functions
3535

3636
valid_float = begin
3737
!!Float(arg) # rubocop:disable Style/DoubleNegation : Could not find a better way to check if a boolean
38-
rescue
38+
rescue StandardError
3939
false
4040
end
4141

lib/puppet/parser/functions/convert_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# convert_base.rb
55
#
66
module Puppet::Parser::Functions
7-
newfunction(:convert_base, type: :rvalue, arity: 2, doc: <<-'DOC') do |args|
7+
newfunction(:convert_base, type: :rvalue, arity: 2, doc: <<-DOC) do |args|
88
@summary
99
Converts a given integer or base 10 string representing an integer to a
1010
specified base, as a string.

lib/puppet/parser/functions/deep_merge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# deep_merge.rb
55
#
66
module Puppet::Parser::Functions
7-
newfunction(:deep_merge, type: :rvalue, doc: <<-'DOC') do |args|
7+
newfunction(:deep_merge, type: :rvalue, doc: <<-DOC) do |args|
88
@summary
99
Recursively merges two or more hashes together and returns the resulting hash.
1010

lib/puppet/parser/functions/getparam.rb

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

6-
Puppet::Parser::Functions.newfunction(:getparam, type: :rvalue, doc: <<-'DOC'
6+
Puppet::Parser::Functions.newfunction(:getparam, type: :rvalue, doc: <<-DOC
77
@summary
88
Returns the value of a resource's parameter.
99

lib/puppet/parser/functions/loadjson.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66

77
module Puppet::Parser::Functions
8-
newfunction(:loadjson, type: :rvalue, arity: -2, doc: <<-'DOC') do |args|
8+
newfunction(:loadjson, type: :rvalue, arity: -2, doc: <<-DOC) do |args|
99
@summary
1010
Load a JSON file containing an array, string, or hash, and return the data
1111
in the corresponding native data type.
@@ -30,12 +30,12 @@ module Puppet::Parser::Functions
3030
begin
3131
if args[0].start_with?('http://', 'https://')
3232
http_options = {}
33-
if (match = args[0].match(%r{(http\://|https\://)(.*):(.*)@(.*)}))
33+
if (match = args[0].match(%r{(http://|https://)(.*):(.*)@(.*)}))
3434
# If URL is in the format of https://username:password@example.local/my_hash.yaml
3535
protocol, username, password, path = match.captures
3636
url = "#{protocol}#{path}"
3737
http_options[:http_basic_authentication] = [username, password]
38-
elsif (match = args[0].match(%r{(http\:\/\/|https\:\/\/)(.*)@(.*)}))
38+
elsif (match = args[0].match(%r{(http://|https://)(.*)@(.*)}))
3939
# If URL is in the format of https://username@example.local/my_hash.yaml
4040
protocol, username, path = match.captures
4141
url = "#{protocol}#{path}"

lib/puppet/parser/functions/loadyaml.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# loadyaml.rb
55
#
66
module Puppet::Parser::Functions
7-
newfunction(:loadyaml, type: :rvalue, arity: -2, doc: <<-'DOC') do |args|
7+
newfunction(:loadyaml, type: :rvalue, arity: -2, doc: <<-DOC) do |args|
88
@summary
99
Load a YAML file containing an array, string, or hash, and return the data
1010
in the corresponding native data type.
@@ -31,11 +31,11 @@ module Puppet::Parser::Functions
3131
if args[0].start_with?('http://', 'https://')
3232
username = ''
3333
password = ''
34-
if (match = args[0].match(%r{(http\://|https\://)(.*):(.*)@(.*)}))
34+
if (match = args[0].match(%r{(http://|https://)(.*):(.*)@(.*)}))
3535
# If URL is in the format of https://username:password@example.local/my_hash.yaml
3636
protocol, username, password, path = match.captures
3737
url = "#{protocol}#{path}"
38-
elsif (match = args[0].match(%r{(http\:\/\/|https\:\/\/)(.*)@(.*)}))
38+
elsif (match = args[0].match(%r{(http://|https://)(.*)@(.*)}))
3939
# If URL is in the format of https://username@example.local/my_hash.yaml
4040
protocol, username, path = match.captures
4141
url = "#{protocol}#{path}"

0 commit comments

Comments
 (0)