Skip to content

Commit 42a1f1a

Browse files
committed
(CONT-801) Autocorrect safe group 1
1 parent ec677d8 commit 42a1f1a

28 files changed

+49
-55
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,6 @@
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 1
10-
# This cop supports safe autocorrection (--autocorrect).
11-
# Configuration parameters: EnforcedStyleAlignWith, Severity.
12-
# SupportedStylesAlignWith: start_of_line, begin
13-
Layout/BeginEndAlignment:
14-
Exclude:
15-
- 'lib/puppet/parser/functions/any2bool.rb'
16-
17-
# Offense count: 33
18-
# This cop supports safe autocorrection (--autocorrect).
19-
Layout/EmptyLineAfterGuardClause:
20-
Enabled: false
21-
22-
# Offense count: 1
23-
# This cop supports safe autocorrection (--autocorrect).
24-
Layout/EmptyLinesAroundArguments:
25-
Exclude:
26-
- 'spec/unit/puppet/provider/file_line/ruby_spec_use_cases.rb'
27-
28-
# Offense count: 1
29-
# This cop supports safe autocorrection (--autocorrect).
30-
# Configuration parameters: AllowAliasSyntax, AllowedMethods.
31-
# AllowedMethods: alias_method, public, protected, private
32-
Layout/EmptyLinesAroundAttributeAccessor:
33-
Exclude:
34-
- 'spec/functions/get_module_path_spec.rb'
35-
36-
# Offense count: 11
37-
# This cop supports safe autocorrection (--autocorrect).
38-
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
39-
# SupportedHashRocketStyles: key, separator, table
40-
# SupportedColonStyles: key, separator, table
41-
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
42-
Layout/HashAlignment:
43-
Exclude:
44-
- 'lib/puppet/parser/functions/pw_hash.rb'
45-
- 'lib/puppet/parser/functions/str2saltedpbkdf2.rb'
46-
- 'spec/functions/str2saltedpbkdf2_spec.rb'
47-
489
# Offense count: 3
4910
# This cop supports safe autocorrection (--autocorrect).
5011
Layout/HeredocIndentation:

lib/puppet/functions/parsehocon.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def parsehocon(hocon_string, default = :no_default_provided)
2525
rescue Hocon::ConfigError::ConfigParseError => err
2626
Puppet.debug("Parsing hocon failed with error: #{err.message}")
2727
raise err if default == :no_default_provided
28+
2829
default
2930
end
3031
end

lib/puppet/functions/parsepson.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def parsepson(pson_string, default = :no_default_provided)
2424
rescue StandardError => err
2525
Puppet.debug("Parsing PSON failed with error: #{err.message}")
2626
raise err if default == :no_default_provided
27+
2728
default
2829
end
2930
end

lib/puppet/parser/functions/any2array.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module Puppet::Parser::Functions
4343
return arguments unless arguments.length == 1
4444
return arguments[0] if arguments[0].is_a?(Array)
4545
return [] if arguments == ['']
46+
4647
if arguments[0].is_a?(Hash)
4748
result = []
4849
arguments[0].each do |key, value|

lib/puppet/parser/functions/any2bool.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,18 @@ module Puppet::Parser::Functions
4040
end
4141

4242
valid_float = begin
43-
!!Float(arg) # rubocop:disable Style/DoubleNegation : Could not find a better way to check if a boolean
44-
rescue
45-
false
46-
end
43+
!!Float(arg) # rubocop:disable Style/DoubleNegation : Could not find a better way to check if a boolean
44+
rescue
45+
false
46+
end
4747

4848
if arg.is_a?(Numeric)
4949
return function_num2bool([arguments[0]])
5050
end
5151

5252
if arg.is_a?(String)
5353
return function_num2bool([arguments[0]]) if valid_float
54+
5455
return function_str2bool([arguments[0]])
5556
end
5657

lib/puppet/parser/functions/basename.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module Puppet::Parser::Functions
1818
rv = File.basename(arguments[0]) if arguments.size == 1
1919
if arguments.size == 2
2020
raise(Puppet::ParseError, 'basename(): Requires string as second argument') unless arguments[1].is_a?(String)
21+
2122
rv = File.basename(arguments[0], arguments[1])
2223
end
2324

lib/puppet/parser/functions/defined_with_params.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
) do |vals|
2727
reference, params = vals
2828
raise(ArgumentError, 'Must specify a reference') unless reference
29+
2930
if !params || params == ''
3031
params = {}
3132
end

lib/puppet/parser/functions/delete_undef_values.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module Puppet::Parser::Functions
3131
unless args[0].is_a?(Array) || args[0].is_a?(Hash)
3232
raise(Puppet::ParseError, "delete_undef_values(): expected an array or hash, got #{args[0]} type #{args[0].class} ")
3333
end
34+
3435
result = args[0].dup
3536
if result.is_a?(Hash)
3637
result.delete_if { |_, val| val.equal?(:undef) || val.nil? }

lib/puppet/parser/functions/delete_values.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module Puppet::Parser::Functions
2929
unless hash.is_a?(Hash)
3030
raise(TypeError, "delete_values(): First argument must be a Hash. Given an argument of class #{hash.class}.")
3131
end
32+
3233
hash.dup.delete_if { |_key, val| item == val }
3334
end
3435
end

lib/puppet/parser/functions/ensure_resource.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
type, title, params = vals
3636
raise(ArgumentError, 'Must specify a type') unless type
3737
raise(ArgumentError, 'Must specify a title') unless title
38+
3839
params ||= {}
3940

4041
items = [title].flatten

0 commit comments

Comments
 (0)