lib/rubocop/cop/style/command_literal.rb in rubocop-0.55.0 vs lib/rubocop/cop/style/command_literal.rb in rubocop-0.56.0
- old
+ new
@@ -93,11 +93,11 @@
def autocorrect(node)
return if contains_backtick?(node)
replacement = if backtick_literal?(node)
- ['%x', ''].zip(preferred_delimiters).map(&:join)
+ ['%x', ''].zip(preferred_delimiter).map(&:join)
else
%w[` `]
end
lambda do |corrector|
@@ -167,12 +167,24 @@
def backtick_literal?(node)
node.loc.begin.source == '`'
end
- def preferred_delimiters
+ def preferred_delimiter
+ (command_delimiter || default_delimiter).split(//)
+ end
+
+ def command_delimiter
+ preferred_delimiters_config['%x']
+ end
+
+ def default_delimiter
+ preferred_delimiters_config['default']
+ end
+
+ def preferred_delimiters_config
config.for_cop('Style/PercentLiteralDelimiters') \
- ['PreferredDelimiters']['%x'].split(//)
+ ['PreferredDelimiters']
end
end
end
end
end