rubocop: fix offences of the Style/FormatString cop

This commit is contained in:
Kyrylo Silin 2019-03-02 02:00:34 +02:00
parent 501e949921
commit 8ea5b6e0aa
5 changed files with 6 additions and 16 deletions

View File

@ -239,17 +239,6 @@ Style/EvalWithLocation:
- 'spec/commands/watch_expression_spec.rb'
- 'spec/method_spec.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
Exclude:
- 'lib/pry/commands/gem_stats.rb'
- 'lib/pry/commands/ls/local_vars.rb'
- 'lib/pry/config/behavior.rb'
- 'lib/pry/pry_class.rb'
# Offense count: 9
# Configuration parameters: EnforcedStyle.
# SupportedStyles: annotated, template, unannotated

View File

@ -65,14 +65,15 @@ VVVVVVVVVVVVVVVVVVVVV
#{red('Dependencies')} (development)
%{ddependencies}
FORMAT
format_str % {
format(
format_str,
name: green(h.name),
version: bold("v#{h.version}"),
downloads: h.downloads,
version_downloads: h.version_downloads,
rdependencies: format_dependencies(h.dependencies.runtime),
ddependencies: format_dependencies(h.dependencies.development)
}
)
end
def format_dependencies(rdeps)

View File

@ -31,7 +31,7 @@ class Pry
colorized_lhs = color(:local_var, lhs)
color_escape_padding = colorized_lhs.size - lhs.size
pad = desired_width + color_escape_padding
"%-#{pad}s = %s" % [color(:local_var, colorized_lhs), rhs]
Kernel.format("%-#{pad}s = %s", color(:local_var, colorized_lhs), rhs)
end
end
end

View File

@ -335,7 +335,7 @@ class Pry
private
def __clip_inspect(obj)
"#{obj.class}:0x%x" % obj.object_id
format("#{obj.class}:0x%x", obj.object_id)
end
def __try_convert_to_hash(obj)

View File

@ -247,7 +247,7 @@ you can add "Pry.config.windows_console_warning = false" to your pryrc.
elsif Pry.config.prompt_safe_contexts.any? { |v| v === obj } && obj.inspect.length <= max
obj.inspect
else
id == true ? "#<#{obj.class}:0x%x>" % (obj.object_id << 1) : "#<#{obj.class}>"
id ? format("#<#{obj.class}:0x%x>", (obj.object_id << 1)) : "#<#{obj.class}>"
end
rescue RescuableException
"unknown"