Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes rubocop violation Style/FormatString #1040

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -555,18 +555,6 @@ Style/FirstParameterIndentation:
Exclude:
- 'spec/cucumber/rake/forked_spec.rb'

# Offense count: 9
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
Exclude:
- 'lib/cucumber/formatter/duration.rb'
- 'lib/cucumber/formatter/junit.rb'
- 'lib/cucumber/formatter/usage.rb'
- 'lib/cucumber/rake/task.rb'
- 'lib/cucumber/rb_support/rb_world.rb'
- 'lib/cucumber/rb_support/snippet.rb'

# Offense count: 13
# Configuration parameters: AllowedVariables.
Style/GlobalVars:
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/formatter/duration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Duration
# <tt>time</tt> format.
def format_duration(seconds)
m, s = seconds.divmod(60)
"#{m}m#{'%.3f' % s}s"
"#{m}m#{format('%.3f', s)}s"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/formatter/junit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def end_feature(feature_data)
:errors => feature_data[:errors],
:skipped => feature_data[:skipped],
:tests => feature_data[:tests],
:time => '%.6f' % feature_data[:time],
:time => format('%.6f', feature_data[:time]),
:name => feature_data[:feature].name ) do
@testsuite << feature_data[:builder].target!
end
Expand Down Expand Up @@ -122,7 +122,7 @@ def build_testcase(result, scenario_designation, output)
classname = @current_feature_data[:feature].name
name = scenario_designation

@current_feature_data[:builder].testcase(:classname => classname, :name => name, :time => '%.6f' % duration) do
@current_feature_data[:builder].testcase(:classname => classname, :name => name, :time => format('%.6f', duration)) do
if !result.passed? && result.ok?(@config.strict?)
@current_feature_data[:builder].skipped
@current_feature_data[:skipped] += 1
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/formatter/usage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def print_summary
end

def print_step_definition(stepdef_key)
@io.print format_string(sprintf('%.7f', stepdef_key.mean_duration), :skipped) + ' ' unless config.dry_run?
@io.print format_string(format('%.7f', stepdef_key.mean_duration), :skipped) + ' ' unless config.dry_run?
@io.print format_string(stepdef_key.regexp_source, stepdef_key.status)
if config.source?
indent = max_length - stepdef_key.regexp_source.unpack('U*').length
Expand All @@ -92,7 +92,7 @@ def print_step_definition(stepdef_key)
def print_steps(stepdef_key)
@stepdef_to_match[stepdef_key].each do |step|
@io.print ' '
@io.print format_string(sprintf('%.7f', step[:duration]), :skipped) + ' ' unless config.dry_run?
@io.print format_string(format('%.7f', step[:duration]), :skipped) + ' ' unless config.dry_run?
@io.print format_step(step[:keyword], step[:step_match], step[:status], nil)
if config.source?
indent = max_length - (step[:keyword].unpack('U*').length + step[:step_match].format_args.unpack('U*').length)
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/rake/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files)
end

def load_path(libs)
['"%s"' % @libs.join(File::PATH_SEPARATOR)]
[format('"%s"', @libs.join(File::PATH_SEPARATOR))]
end

def quoted_binary(cucumber_bin)
['"%s"' % cucumber_bin]
[format('"%s"', cucumber_bin)]
end

def use_bundler
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/rb_support/rb_world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def inspect
modules += included_modules
end
modules << stringify_namespaced_modules
sprintf('#<%s:0x%x>', modules.join('+'), self.object_id)
format('#<%s:0x%x>', modules.join('+'), self.object_id)
end

# see {#inspect}
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/rb_support/snippet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def step
end

def self.cli_option_string(type)
'%-7s: %-28s e.g. %s' % [type, description, example]
format('%-7s: %-28s e.g. %s', type, description, example)
end

private
Expand Down