Skip to content

Commit 0cc6f84

Browse files
committed
(PUP-11993) Style/StringLiteralsInInterpolation
This commit enables the Style/StringLiteralsInInterpolation cop and fixes 23 autocorrectable offenses.
1 parent 1af46d8 commit 0cc6f84

File tree

19 files changed

+21
-27
lines changed

19 files changed

+21
-27
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -722,12 +722,6 @@ Style/StringConcatenation:
722722
Style/StringLiterals:
723723
Enabled: false
724724

725-
# This cop supports safe auto-correction (--auto-correct).
726-
# Configuration parameters: EnforcedStyle.
727-
# SupportedStyles: single_quotes, double_quotes
728-
Style/StringLiteralsInInterpolation:
729-
Enabled: false
730-
731725
# This cop supports safe auto-correction (--auto-correct).
732726
# Configuration parameters: EnforcedStyle, MinSize.
733727
# SupportedStyles: percent, brackets

lib/puppet/confine/variable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def initialize(values)
2929
end
3030

3131
def message(value)
32-
"facter value '#{test_value}' for '#{name}' not in required list '#{values.join(",")}'"
32+
"facter value '#{test_value}' for '#{name}' not in required list '#{values.join(',')}'"
3333
end
3434

3535
# Compare the passed-in value to the retrieved value.

lib/puppet/interface/action.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def when_invoked=(block)
254254
file = __FILE__ + "+eval[wrapper]"
255255
line = __LINE__ + 2 # <== points to the same line as 'def' in the wrapper.
256256
wrapper = <<~WRAPPER
257-
def #{@name}(#{decl.join(", ")})
257+
def #{@name}(#{decl.join(', ')})
258258
#{optn}
259259
args = #{args}
260260
action = get_action(#{name.inspect})

lib/puppet/interface/action_manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def get_action(name)
8080
def get_default_action
8181
default = actions.map { |x| get_action(x) }.select { |x| x.default }
8282
if default.length > 1
83-
raise "The actions #{default.map(&:name).join(", ")} cannot all be default"
83+
raise "The actions #{default.map(&:name).join(', ')} cannot all be default"
8484
end
8585

8686
default.first

lib/puppet/node/environment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def to_s
518518

519519
# @api public
520520
def inspect
521-
%Q(<#{self.class}:#{object_id} @name="#{name}" @manifest="#{manifest}" @modulepath="#{full_modulepath.join(":")}" >)
521+
%Q(<#{self.class}:#{object_id} @name="#{name}" @manifest="#{manifest}" @modulepath="#{full_modulepath.join(':')}" >)
522522
end
523523

524524
# @return [Symbol] The `name` value, cast to a string, then cast to a symbol.

lib/puppet/parameter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def doc
121121

122122
features = required_features
123123
if features
124-
@doc << "\n\nRequires features #{features.flatten.collect { |f| f.to_s }.join(" ")}."
124+
@doc << "\n\nRequires features #{features.flatten.collect { |f| f.to_s }.join(' ')}."
125125
end
126126
@addeddocvals = true
127127
end

lib/puppet/parameter/value_collection.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ def doc
3737
@doc << @strings.collect do |value|
3838
aliases = value.aliases
3939
if aliases && !aliases.empty?
40-
"`#{value.name}` (also called `#{aliases.join(", ")}`)"
40+
"`#{value.name}` (also called `#{aliases.join(', ')}`)"
4141
else
4242
"`#{value.name}`"
4343
end
4444
end.join(", ") << ". "
4545
end
4646

4747
unless regexes.empty?
48-
@doc << "Values can match `#{regexes.join("`, `")}`."
48+
@doc << "Values can match `#{regexes.join('`, `')}`."
4949
end
5050
end
5151

lib/puppet/parser/functions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def self.functiondocs(environment = Puppet.lookup(:current_environment))
263263
ret = ''.dup
264264

265265
merged_functions(environment).sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |name, hash|
266-
ret << "#{name}\n#{"-" * name.to_s.length}\n"
266+
ret << "#{name}\n#{'-' * name.to_s.length}\n"
267267
if hash[:doc]
268268
ret << Puppet::Util::Docs.scrub(hash[:doc])
269269
else

lib/puppet/parser/templatewrapper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@ def result(string = nil)
100100
end
101101

102102
def to_s
103-
"template[#{@__file__ || "inline"}]"
103+
"template[#{@__file__ || 'inline'}]"
104104
end
105105
end

lib/puppet/pops/evaluator/runtime3_converter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def convert_Integer(o, scope, undef_value)
7070
return o unless o < MIN_INTEGER || o > MAX_INTEGER
7171

7272
range_end = o > MAX_INTEGER ? 'max' : 'min'
73-
raise Puppet::Error, "Use of a Ruby Integer outside of Puppet Integer #{range_end} range, got '#{"0x%x" % o}'"
73+
raise Puppet::Error, "Use of a Ruby Integer outside of Puppet Integer #{range_end} range, got '#{'0x%x' % o}'"
7474
end
7575

7676
def convert_BigDecimal(o, scope, undef_value)

0 commit comments

Comments
 (0)