From 4c189c25863e912d65f4549551f1e3077b2c94b4 Mon Sep 17 00:00:00 2001 From: Andrea Nodari Date: Fri, 16 Sep 2016 09:33:08 +0100 Subject: [PATCH 01/13] Fix style violations Remove style violations specified in .rubocop.yml, the remaining violations are automatically ignore by .rubocop_todo.yml. --- .rubocop.yml | 10 -------- features/lib/support/normalise_output.rb | 9 +++---- lib/autotest/cucumber_mixin.rb | 10 ++++---- lib/cucumber/cli/options.rb | 12 ++++----- lib/cucumber/formatter/console.rb | 22 ++++++++--------- lib/cucumber/formatter/json.rb | 10 ++++---- lib/cucumber/formatter/legacy_api/adapter.rb | 10 ++++---- lib/cucumber/formatter/legacy_api/ast.rb | 14 +++++------ lib/cucumber/formatter/legacy_api/results.rb | 14 +++++------ lib/cucumber/formatter/progress.rb | 19 +++++++------- lib/cucumber/formatter/usage.rb | 10 ++++---- lib/cucumber/rb_support/rb_transform.rb | 7 +++--- lib/cucumber/runtime/user_interface.rb | 9 +++---- spec/cucumber/formatter/json_spec.rb | 10 +++----- spec/cucumber/formatter/junit_spec.rb | 26 +++++++++----------- 15 files changed, 81 insertions(+), 111 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 61f99f19a6..cc32da4b99 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,11 +1 @@ inherit_from: .rubocop_todo.yml - -# FIXME: These style issues are not part of the automatically generated -# .rubocop_todo.yml config. -Style/GuardClause: - Enabled: false - -# FIXME: These style issues are not part of the automatically generated -# .rubocop_todo.yml config. -Style/ConditionalAssignment: - Enabled: false diff --git a/features/lib/support/normalise_output.rb b/features/lib/support/normalise_output.rb index b1c338818d..db625fda16 100644 --- a/features/lib/support/normalise_output.rb +++ b/features/lib/support/normalise_output.rb @@ -38,12 +38,9 @@ def normalise_json(json) end def normalise_json_step_or_hook(step_or_hook) - if step_or_hook['result'] - if step_or_hook['result']['duration'] - expect(step_or_hook['result']['duration']).to be >= 0 - step_or_hook['result']['duration'] = 1 - end - end + return unless step_or_hook['result'] && step_or_hook['result']['duration'] + expect(step_or_hook['result']['duration']).to be >= 0 + step_or_hook['result']['duration'] = 1 end end diff --git a/lib/autotest/cucumber_mixin.rb b/lib/autotest/cucumber_mixin.rb index 4f47ff544f..4084b80b7c 100644 --- a/lib/autotest/cucumber_mixin.rb +++ b/lib/autotest/cucumber_mixin.rb @@ -115,11 +115,11 @@ def make_cucumber_cmd(features_to_run, dirty_features_filename) profile ||= "autotest" if profile_loader.has_profile?("autotest") profile ||= nil - if profile - args = ["--profile", profile] - else - args = %w{--format} << (features_to_run == :all ? "progress" : "pretty") - end + args = if profile + ["--profile", profile] + else + %w{--format} << (features_to_run == :all ? "progress" : "pretty") + end # No --color option as some IDEs (Netbeans) don't output them very well (1 failed step) args += %w{--format rerun --out} << dirty_features_filename args << (features_to_run == :all ? "" : features_to_run) diff --git a/lib/cucumber/cli/options.rb b/lib/cucumber/cli/options.rb index 420b199ef8..b1e9a20807 100644 --- a/lib/cucumber/cli/options.rb +++ b/lib/cucumber/cli/options.rb @@ -161,9 +161,8 @@ def filters def check_formatter_stream_conflicts() streams = @options[:formats].uniq.map { |(_, stream)| stream } - if streams != streams.uniq - raise "All but one formatter must use --out, only one can print to each stream (or STDOUT)" - end + return if streams == streams.uniq + raise "All but one formatter must use --out, only one can print to each stream (or STDOUT)" end def to_hash @@ -311,10 +310,9 @@ def banner def require_files(v) @options[:require] << v - if(Cucumber::JRUBY && File.directory?(v)) - require 'java' - $CLASSPATH << v - end + return unless Cucumber::JRUBY && File.directory?(v) + require 'java' + $CLASSPATH << v end def require_jars(jars) diff --git a/lib/cucumber/formatter/console.rb b/lib/cucumber/formatter/console.rb index 4c82ca7646..4db9b43032 100644 --- a/lib/cucumber/formatter/console.rb +++ b/lib/cucumber/formatter/console.rb @@ -116,13 +116,11 @@ def linebreaks(s, max) def collect_snippet_data(test_step, result) # collect snippet data for undefined steps - unless hook?(test_step) - keyword = test_step.source.last.actual_keyword(@previous_step_keyword) - @previous_step_keyword = keyword - if result.undefined? - @snippets_input << Console::SnippetData.new(keyword, test_step.source.last) - end - end + return if hook?(test_step) + keyword = test_step.source.last.actual_keyword(@previous_step_keyword) + @previous_step_keyword = keyword + return unless result.undefined? + @snippets_input << Console::SnippetData.new(keyword, test_step.source.last) end def print_snippets(options) @@ -234,11 +232,11 @@ def hook?(test_step) def element_messages(elements, status) element_messages = elements.map do |element| - if status == :failed - message = exception_message_string(element.exception, 0) - else - message = linebreaks(element.backtrace_line, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i) - end + message = if status == :failed + exception_message_string(element.exception, 0) + else + linebreaks(element.backtrace_line, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i) + end end end diff --git a/lib/cucumber/formatter/json.rb b/lib/cucumber/formatter/json.rb index 1c7f74511a..23f8e10fe3 100644 --- a/lib/cucumber/formatter/json.rb +++ b/lib/cucumber/formatter/json.rb @@ -245,11 +245,11 @@ def feature(feature) } unless feature.tags.empty? @feature_hash[:tags] = create_tags_array(feature.tags) - if @test_case_hash[:tags] - @test_case_hash[:tags] = @feature_hash[:tags] + @test_case_hash[:tags] - else - @test_case_hash[:tags] = @feature_hash[:tags] - end + @test_case_hash[:tags] = if @test_case_hash[:tags] + @feature_hash[:tags] + @test_case_hash[:tags] + else + @feature_hash[:tags] + end end @feature_hash[:comments] = Formatter.create_comments_array(feature.comments) unless feature.comments.empty? @test_case_hash[:id].insert(0, @feature_hash[:id] + ';') diff --git a/lib/cucumber/formatter/legacy_api/adapter.rb b/lib/cucumber/formatter/legacy_api/adapter.rb index d0c3c2395f..75e78e7136 100644 --- a/lib/cucumber/formatter/legacy_api/adapter.rb +++ b/lib/cucumber/formatter/legacy_api/adapter.rb @@ -699,11 +699,11 @@ def examples_table_row(examples_table_row, before_hook_results) return if examples_table_row == @current @child.after if @child row = ExampleTableRow.new(examples_table_row) - if !configuration.expand? - @child = TableRowPrinter.new(formatter, row, before_hook_results).before - else - @child = ExpandTableRowPrinter.new(formatter, row, before_hook_results).before - end + @child = if !configuration.expand? + TableRowPrinter.new(formatter, row, before_hook_results).before + else + ExpandTableRowPrinter.new(formatter, row, before_hook_results).before + end @current = examples_table_row end diff --git a/lib/cucumber/formatter/legacy_api/ast.rb b/lib/cucumber/formatter/legacy_api/ast.rb index 7921d4c24f..029aaeaf4e 100644 --- a/lib/cucumber/formatter/legacy_api/ast.rb +++ b/lib/cucumber/formatter/legacy_api/ast.rb @@ -80,17 +80,15 @@ def accept(formatter) end def send_output_to(formatter) - unless @already_accepted - @messages.each { |message| formatter.puts(message) } - @embeddings.each { |embedding| embedding.send_to_formatter(formatter) } - end + return if @already_accepted + @messages.each { |message| formatter.puts(message) } + @embeddings.each { |embedding| embedding.send_to_formatter(formatter) } end def describe_exception_to(formatter) - unless @already_accepted - @result.describe_exception_to(formatter) - @already_accepted = true - end + return if @already_accepted + @result.describe_exception_to(formatter) + @already_accepted = true end end diff --git a/lib/cucumber/formatter/legacy_api/results.rb b/lib/cucumber/formatter/legacy_api/results.rb index 59c546c683..a75d3bd610 100644 --- a/lib/cucumber/formatter/legacy_api/results.rb +++ b/lib/cucumber/formatter/legacy_api/results.rb @@ -13,19 +13,17 @@ def initialize def step_visited(step) #:nodoc: step_id = step.object_id - unless @inserted_steps.has_key?(step_id) - @inserted_steps[step_id] = step - steps.push(step) - end + return if @inserted_steps.has_key?(step_id) + @inserted_steps[step_id] = step + steps.push(step) end def scenario_visited(scenario) #:nodoc: scenario_id = scenario.object_id - unless @inserted_scenarios.has_key?(scenario_id) - @inserted_scenarios[scenario_id] = scenario - scenarios.push(scenario) - end + return if @inserted_scenarios.has_key?(scenario_id) + @inserted_scenarios[scenario_id] = scenario + scenarios.push(scenario) end def steps(status = nil) #:nodoc: diff --git a/lib/cucumber/formatter/progress.rb b/lib/cucumber/formatter/progress.rb index eb0823579e..610197144a 100644 --- a/lib/cucumber/formatter/progress.rb +++ b/lib/cucumber/formatter/progress.rb @@ -53,11 +53,11 @@ def on_test_step_finished(event) test_step = event.test_step result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter) progress(result.to_sym) if !HookQueryVisitor.new(test_step).hook? || result.failed? - unless HookQueryVisitor.new(test_step).hook? - collect_snippet_data(test_step, result) - @pending_step_matches << @matches[test_step.source] if result.pending? - @failed_results << result if result.failed? - end + + return if HookQueryVisitor.new(test_step).hook? + collect_snippet_data(test_step, result) + @pending_step_matches << @matches[test_step.source] if result.pending? + @failed_results << result if result.failed? end def on_test_case_finished(event) @@ -84,12 +84,11 @@ def print_summary snippet_text(step_keyword, step_name, multiline_arg) } do_print_snippets(snippet_text_proc) if config.snippets? && summary.test_steps.total(:undefined) > 0 - if config.wip? - messages = @passed_test_cases.map do |test_case| - message = linebreaks("#{test_case.location.on_line(test_case.location.line)}:in `#{test_case.name}'", ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i) - end - do_print_passing_wip(messages) + return unless config.wip? + messages = @passed_test_cases.map do |test_case| + message = linebreaks("#{test_case.location.on_line(test_case.location.line)}:in `#{test_case.name}'", ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i) end + do_print_passing_wip(messages) end CHARS = { diff --git a/lib/cucumber/formatter/usage.rb b/lib/cucumber/formatter/usage.rb index 7edcc19333..648152c7af 100644 --- a/lib/cucumber/formatter/usage.rb +++ b/lib/cucumber/formatter/usage.rb @@ -59,11 +59,11 @@ def on_test_step_finished(event) def print_summary aggregate_info - if config.dry_run? - keys = @stepdef_to_match.keys.sort {|a,b| a.regexp_source <=> b.regexp_source} - else - keys = @stepdef_to_match.keys.sort {|a,b| a.mean_duration <=> b.mean_duration}.reverse - end + keys = if config.dry_run? + @stepdef_to_match.keys.sort {|a,b| a.regexp_source <=> b.regexp_source} + else + @stepdef_to_match.keys.sort {|a,b| a.mean_duration <=> b.mean_duration}.reverse + end keys.each do |stepdef_key| print_step_definition(stepdef_key) diff --git a/lib/cucumber/rb_support/rb_transform.rb b/lib/cucumber/rb_support/rb_transform.rb index bf056cf352..5c75340df2 100644 --- a/lib/cucumber/rb_support/rb_transform.rb +++ b/lib/cucumber/rb_support/rb_transform.rb @@ -28,10 +28,9 @@ def match(arg) end def invoke(arg) - if matched = match(arg) - args = matched.captures.empty? ? [arg] : matched.captures - @rb_language.current_world.cucumber_instance_exec(true, @regexp.inspect, *args, &@proc) - end + return unless matched = match(arg) + args = matched.captures.empty? ? [arg] : matched.captures + @rb_language.current_world.cucumber_instance_exec(true, @regexp.inspect, *args, &@proc) end def to_s diff --git a/lib/cucumber/runtime/user_interface.rb b/lib/cucumber/runtime/user_interface.rb index a478cef2bc..d9f63f5a17 100644 --- a/lib/cucumber/runtime/user_interface.rb +++ b/lib/cucumber/runtime/user_interface.rb @@ -43,12 +43,9 @@ def ask(question, timeout_seconds) answer = mri_gets(timeout_seconds) end - if(answer) - puts(answer) - answer - else - raise("Waited for input for #{timeout_seconds} seconds, then timed out.") - end + raise("Waited for input for #{timeout_seconds} seconds, then timed out.") unless answer + puts(answer) + answer end # Embed +src+ of MIME type +mime_type+ into the output. The +src+ argument may diff --git a/spec/cucumber/formatter/json_spec.rb b/spec/cucumber/formatter/json_spec.rb index 7ff6d1923b..0ced33ed0e 100644 --- a/spec/cucumber/formatter/json_spec.rb +++ b/spec/cucumber/formatter/json_spec.rb @@ -829,12 +829,10 @@ def normalise_json(json) end def normalise_json_step_or_hook(step_or_hook) - if step_or_hook['result'] - if step_or_hook['result']['duration'] - expect(step_or_hook['result']['duration']).to be >= 0 - step_or_hook['result']['duration'] = 1 - end - end + return unless step_or_hook['result'] && step_or_hook['result']['duration'] + + expect(step_or_hook['result']['duration']).to be >= 0 + step_or_hook['result']['duration'] = 1 end end diff --git a/spec/cucumber/formatter/junit_spec.rb b/spec/cucumber/formatter/junit_spec.rb index b4147da163..9c973d7cdd 100644 --- a/spec/cucumber/formatter/junit_spec.rb +++ b/spec/cucumber/formatter/junit_spec.rb @@ -43,20 +43,18 @@ def write_file(feature_filename, data) " class Junit def before_step(step) - if step.name.match("a passing ctrl scenario") - Interceptor::Pipe.unwrap! :stdout - @fake_io = $stdout = StringIO.new - $stdout.sync = true - @interceptedout = Interceptor::Pipe.wrap(:stdout) - end + return unless step.name.match("a passing ctrl scenario") + Interceptor::Pipe.unwrap! :stdout + @fake_io = $stdout = StringIO.new + $stdout.sync = true + @interceptedout = Interceptor::Pipe.wrap(:stdout) end def after_step(step) - if step.name.match("a passing ctrl scenario") - @interceptedout.write("boo\b\cx\e\a\f boo ") - $stdout = STDOUT - @fake_io.close - end + return unless step.name.match("a passing ctrl scenario") + @interceptedout.write("boo\b\cx\e\a\f boo ") + $stdout = STDOUT + @fake_io.close end end @@ -196,7 +194,7 @@ def after_step(step) end end end - + context "In --expand mode" do let(:runtime) { Runtime.new({:expand => true}) } before(:each) do @@ -213,7 +211,7 @@ def after_step(step) run_defined_feature @doc = Nokogiri.XML(@formatter.written_files.values.first) end - + describe "with a scenario outline table" do define_steps do Given(/.*/) { } @@ -246,7 +244,7 @@ def after_step(step) it { expect(@doc.to_s).not_to match /type="skipped"/} end end - + end end end From 9f296314d2aaf5851153482d547c2d1f7a63a7f6 Mon Sep 17 00:00:00 2001 From: Konstantin Bukley Date: Fri, 16 Sep 2016 13:51:27 +0300 Subject: [PATCH 02/13] Fix rubocop violations * Hash#has_key? => Hash#key? * Lint/BlockAlignment * Lint/DefEndAlignment --- .rubocop_todo.yml | 15 --------------- lib/cucumber/cli/profile_loader.rb | 4 ++-- lib/cucumber/formatter/ansicolor.rb | 2 +- lib/cucumber/formatter/html.rb | 4 ++-- lib/cucumber/formatter/legacy_api/results.rb | 4 ++-- lib/cucumber/multiline_argument/data_table.rb | 2 +- 6 files changed, 8 insertions(+), 23 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 67a10cdea6..1f3a91f534 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -30,21 +30,6 @@ Lint/AssignmentInCondition: - 'lib/cucumber/runtime/support_code.rb' - 'spec/cucumber/formatter/spec_helper.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AlignWith, SupportedStyles. -# SupportedStyles: either, start_of_block, start_of_line -Lint/BlockAlignment: - Exclude: - - 'lib/cucumber/formatter/html.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect. -# SupportedStyles: start_of_line, def -Lint/DefEndAlignment: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. Lint/DeprecatedClassMethods: diff --git a/lib/cucumber/cli/profile_loader.rb b/lib/cucumber/cli/profile_loader.rb index 6c5c688771..7c08617477 100644 --- a/lib/cucumber/cli/profile_loader.rb +++ b/lib/cucumber/cli/profile_loader.rb @@ -11,7 +11,7 @@ def initialize end def args_from(profile) - unless cucumber_yml.has_key?(profile) + unless cucumber_yml.key?(profile) raise(ProfileNotFound, <<-END_OF_ERROR) Could not find profile: '#{profile}' @@ -42,7 +42,7 @@ def args_from(profile) end def has_profile?(profile) - cucumber_yml.has_key?(profile) + cucumber_yml.key?(profile) end def cucumber_yml_defined? diff --git a/lib/cucumber/formatter/ansicolor.rb b/lib/cucumber/formatter/ansicolor.rb index 9cb278d1ea..e16028c237 100644 --- a/lib/cucumber/formatter/ansicolor.rb +++ b/lib/cucumber/formatter/ansicolor.rb @@ -9,7 +9,7 @@ end end -Cucumber::Term::ANSIColor.coloring = false if !STDOUT.tty? && !ENV.has_key?("AUTOTEST") +Cucumber::Term::ANSIColor.coloring = false if !STDOUT.tty? && !ENV.key?("AUTOTEST") module Cucumber module Formatter diff --git a/lib/cucumber/formatter/html.rb b/lib/cucumber/formatter/html.rb index da7371d003..3d005b6263 100644 --- a/lib/cucumber/formatter/html.rb +++ b/lib/cucumber/formatter/html.rb @@ -85,7 +85,7 @@ def before_features(features) ) @builder << '' - @builder.head do + @builder.head do @builder.meta('http-equiv' => 'Content-Type', :content => 'text/html;charset=utf-8') @builder.title 'Cucumber' inline_css @@ -590,7 +590,7 @@ def format_exception(exception) (["#{exception.message}"] + exception.backtrace).join("\n") end - def backtrace_line(line) + def backtrace_line(line) if ENV['TM_PROJECT_DIRECTORY'] line.gsub(/^([^:]*\.(?:rb|feature|haml)):(\d*).*$/) do "#{$1}:#{$2} " diff --git a/lib/cucumber/formatter/legacy_api/results.rb b/lib/cucumber/formatter/legacy_api/results.rb index 59c546c683..3faf6b45c2 100644 --- a/lib/cucumber/formatter/legacy_api/results.rb +++ b/lib/cucumber/formatter/legacy_api/results.rb @@ -13,7 +13,7 @@ def initialize def step_visited(step) #:nodoc: step_id = step.object_id - unless @inserted_steps.has_key?(step_id) + unless @inserted_steps.key?(step_id) @inserted_steps[step_id] = step steps.push(step) end @@ -22,7 +22,7 @@ def step_visited(step) #:nodoc: def scenario_visited(scenario) #:nodoc: scenario_id = scenario.object_id - unless @inserted_scenarios.has_key?(scenario_id) + unless @inserted_scenarios.key?(scenario_id) @inserted_scenarios[scenario_id] = scenario scenarios.push(scenario) end diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index 4452236578..c200e69c54 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -556,7 +556,7 @@ def convert_headers! #:nodoc: raise "No headers matched #{pre.inspect}" if mapped_cells.empty? raise "#{mapped_cells.length} headers matched #{pre.inspect}: #{mapped_cells.map { |c| c.value }.inspect}" if mapped_cells.length > 1 mapped_cells[0].value = post - if @conversion_procs.has_key?(pre) + if @conversion_procs.key?(pre) @conversion_procs[post] = @conversion_procs.delete(pre) end end From 562b04c89ee4a21ed1a4b385c8cccd63aad93996 Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Thu, 22 Sep 2016 16:39:40 +0100 Subject: [PATCH 03/13] Update History --- History.md | 1 + 1 file changed, 1 insertion(+) diff --git a/History.md b/History.md index fa3e5c0e1a..03010a8450 100644 --- a/History.md +++ b/History.md @@ -24,6 +24,7 @@ * Several tests failing with rbenv ([#1017](https://github.com/cucumber/cucumber-ruby/issues/1017) @nodo) * Add rubocop to check the style of the codebase ([1014](https://github.com/cucumber/cucumber-ruby/issues/1014) @nodo) * Fix the rubocop violation 'Lint/AmbiguousRegexpLiteral' ([1025](https://github.com/cucumber/cucumber-ruby/pull/1025) @pmatsinopoulos) +* Fix rubocop violations ([#1024](https://github.com/cucumber/cucumber-ruby/pull/1024) @madundead) ## [v2.4.0](https://github.com/cucumber/cucumber-ruby/compare/v2.3.3...v2.4.0) From a29179830fb3fb4487841f37d0b6aea05c3cd851 Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Thu, 22 Sep 2016 16:44:09 +0100 Subject: [PATCH 04/13] Update History --- History.md | 1 + 1 file changed, 1 insertion(+) diff --git a/History.md b/History.md index 03010a8450..0f7546614c 100644 --- a/History.md +++ b/History.md @@ -25,6 +25,7 @@ * Add rubocop to check the style of the codebase ([1014](https://github.com/cucumber/cucumber-ruby/issues/1014) @nodo) * Fix the rubocop violation 'Lint/AmbiguousRegexpLiteral' ([1025](https://github.com/cucumber/cucumber-ruby/pull/1025) @pmatsinopoulos) * Fix rubocop violations ([#1024](https://github.com/cucumber/cucumber-ruby/pull/1024) @madundead) +* Fix style violations ([#1023](https://github.com/cucumber/cucumber-ruby/pull/1023) @nodo) ## [v2.4.0](https://github.com/cucumber/cucumber-ruby/compare/v2.3.3...v2.4.0) From 3ba1f44f5fe335dec9c2fe325c66a5297a549933 Mon Sep 17 00:00:00 2001 From: hotovson Date: Fri, 23 Sep 2016 10:45:00 +0200 Subject: [PATCH 05/13] fix Lint/UselessAssignment --- .rubocop_todo.yml | 4 ---- examples/i18n/ar/lib/calculator.rb | 2 +- examples/i18n/ca/lib/calculadora.rb | 4 ++-- examples/i18n/cs/lib/calculator.rb | 6 +++--- examples/i18n/da/lib/lommeregner.rb | 2 +- examples/i18n/de/lib/calculator.rb | 2 +- examples/i18n/el/lib/calculator.rb | 2 +- examples/i18n/en/lib/calculator.rb | 2 +- examples/i18n/eo/lib/calculator.rb | 2 +- examples/i18n/es/lib/calculador.rb | 2 +- examples/i18n/et/lib/kalkulaator.rb | 2 +- examples/i18n/fi/lib/laskin.rb | 2 +- examples/i18n/fr/lib/calculatrice.rb | 2 +- examples/i18n/he/lib/calculator.rb | 2 +- examples/i18n/hi/lib/calculator.rb | 2 +- examples/i18n/ht/lib/kalkilatris.rb | 2 +- examples/i18n/hu/lib/calculator.rb | 2 +- examples/i18n/id/lib/calculator.rb | 2 +- examples/i18n/it/lib/calcolatrice.rb | 6 +++--- examples/i18n/ja/lib/calculator.rb | 2 +- examples/i18n/ko/lib/calculator.rb | 2 +- examples/i18n/lt/lib/calculator.rb | 2 +- examples/i18n/lv/lib/calculator.rb | 2 +- examples/i18n/no/lib/kalkulator.rb | 2 +- examples/i18n/pl/lib/calculator.rb | 2 +- examples/i18n/pt/lib/calculadora.rb | 2 +- examples/i18n/ro/lib/calculator.rb | 2 +- examples/i18n/sk/lib/calculator.rb | 2 +- examples/i18n/sr-Cyrl/lib/calculator.rb | 2 +- examples/i18n/sr-Latn/lib/calculator.rb | 2 +- examples/i18n/sv/lib/kalkulator.rb | 2 +- examples/i18n/tr/lib/hesap_makinesi.rb | 2 +- examples/i18n/zh-CN/lib/calculator.rb | 2 +- examples/i18n/zh-TW/lib/calculator.rb | 2 +- features/lib/support/normalise_output.rb | 10 +++++----- lib/cucumber/cli/profile_loader.rb | 5 ++--- lib/cucumber/formatter/console.rb | 15 +++++++-------- lib/cucumber/formatter/fail_fast.rb | 2 +- lib/cucumber/formatter/html.rb | 12 +++++++++--- lib/cucumber/formatter/json.rb | 2 +- lib/cucumber/formatter/legacy_api/adapter.rb | 6 +++--- lib/cucumber/formatter/progress.rb | 2 +- spec/cucumber/formatter/spec_helper.rb | 2 +- .../rb_support/rb_step_definition_spec.rb | 1 - spec/cucumber/step_match_search_spec.rb | 13 ++++++------- 45 files changed, 74 insertions(+), 76 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3973e35be2..a22aff30c2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -123,10 +123,6 @@ Lint/UselessAccessModifier: Exclude: - 'lib/cucumber/multiline_argument/data_table.rb' -# Offense count: 56 -Lint/UselessAssignment: - Enabled: false - # Offense count: 60 Metrics/AbcSize: Max: 99 diff --git a/examples/i18n/ar/lib/calculator.rb b/examples/i18n/ar/lib/calculator.rb index 86b1a09b55..c985898c09 100644 --- a/examples/i18n/ar/lib/calculator.rb +++ b/examples/i18n/ar/lib/calculator.rb @@ -6,6 +6,6 @@ def push(n) end def جمع - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end end \ No newline at end of file diff --git a/examples/i18n/ca/lib/calculadora.rb b/examples/i18n/ca/lib/calculadora.rb index 75b427f160..a790d37a73 100644 --- a/examples/i18n/ca/lib/calculadora.rb +++ b/examples/i18n/ca/lib/calculadora.rb @@ -6,11 +6,11 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide @args[0].to_f / @args[1].to_f end -end \ No newline at end of file +end diff --git a/examples/i18n/cs/lib/calculator.rb b/examples/i18n/cs/lib/calculator.rb index 0598d3e627..7a607963f1 100644 --- a/examples/i18n/cs/lib/calculator.rb +++ b/examples/i18n/cs/lib/calculator.rb @@ -3,12 +3,12 @@ def push(n) @args ||= [] @args << n end - + def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide @args[0].to_f / @args[1].to_f end -end \ No newline at end of file +end diff --git a/examples/i18n/da/lib/lommeregner.rb b/examples/i18n/da/lib/lommeregner.rb index 4876c25787..3d7f2e971d 100644 --- a/examples/i18n/da/lib/lommeregner.rb +++ b/examples/i18n/da/lib/lommeregner.rb @@ -6,6 +6,6 @@ def push(n) def add #@args[0] + @args[1] - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end end diff --git a/examples/i18n/de/lib/calculator.rb b/examples/i18n/de/lib/calculator.rb index 0598d3e627..ef1947f179 100644 --- a/examples/i18n/de/lib/calculator.rb +++ b/examples/i18n/de/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/el/lib/calculator.rb b/examples/i18n/el/lib/calculator.rb index 0598d3e627..ef1947f179 100644 --- a/examples/i18n/el/lib/calculator.rb +++ b/examples/i18n/el/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/en/lib/calculator.rb b/examples/i18n/en/lib/calculator.rb index 0598d3e627..ef1947f179 100644 --- a/examples/i18n/en/lib/calculator.rb +++ b/examples/i18n/en/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/eo/lib/calculator.rb b/examples/i18n/eo/lib/calculator.rb index 0598d3e627..ef1947f179 100644 --- a/examples/i18n/eo/lib/calculator.rb +++ b/examples/i18n/eo/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/es/lib/calculador.rb b/examples/i18n/es/lib/calculador.rb index b7db592a5e..d48539aa8b 100644 --- a/examples/i18n/es/lib/calculador.rb +++ b/examples/i18n/es/lib/calculador.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/et/lib/kalkulaator.rb b/examples/i18n/et/lib/kalkulaator.rb index 3e75a741e5..0deb096d68 100644 --- a/examples/i18n/et/lib/kalkulaator.rb +++ b/examples/i18n/et/lib/kalkulaator.rb @@ -5,7 +5,7 @@ def push(n) end def liida - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def jaga diff --git a/examples/i18n/fi/lib/laskin.rb b/examples/i18n/fi/lib/laskin.rb index 5e1946c9d1..7eead133f8 100644 --- a/examples/i18n/fi/lib/laskin.rb +++ b/examples/i18n/fi/lib/laskin.rb @@ -5,7 +5,7 @@ def pinoa(n) end def summaa - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def jaa diff --git a/examples/i18n/fr/lib/calculatrice.rb b/examples/i18n/fr/lib/calculatrice.rb index f92cddb3e4..82c7220650 100644 --- a/examples/i18n/fr/lib/calculatrice.rb +++ b/examples/i18n/fr/lib/calculatrice.rb @@ -5,6 +5,6 @@ def push(n) end def additionner - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end end diff --git a/examples/i18n/he/lib/calculator.rb b/examples/i18n/he/lib/calculator.rb index ff623a1d35..e5b9d69f27 100644 --- a/examples/i18n/he/lib/calculator.rb +++ b/examples/i18n/he/lib/calculator.rb @@ -6,7 +6,7 @@ def push(n) end def חבר - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def חלק diff --git a/examples/i18n/hi/lib/calculator.rb b/examples/i18n/hi/lib/calculator.rb index 844f005f8c..f6a8a275c1 100644 --- a/examples/i18n/hi/lib/calculator.rb +++ b/examples/i18n/hi/lib/calculator.rb @@ -6,7 +6,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/ht/lib/kalkilatris.rb b/examples/i18n/ht/lib/kalkilatris.rb index 53fde2f027..abc321cb30 100644 --- a/examples/i18n/ht/lib/kalkilatris.rb +++ b/examples/i18n/ht/lib/kalkilatris.rb @@ -5,7 +5,7 @@ def push(n) end def ajoute - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divize diff --git a/examples/i18n/hu/lib/calculator.rb b/examples/i18n/hu/lib/calculator.rb index 2949fd4d18..7a607963f1 100644 --- a/examples/i18n/hu/lib/calculator.rb +++ b/examples/i18n/hu/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/id/lib/calculator.rb b/examples/i18n/id/lib/calculator.rb index 0598d3e627..ef1947f179 100644 --- a/examples/i18n/id/lib/calculator.rb +++ b/examples/i18n/id/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/it/lib/calcolatrice.rb b/examples/i18n/it/lib/calcolatrice.rb index 82d91844b3..91d6f5df92 100644 --- a/examples/i18n/it/lib/calcolatrice.rb +++ b/examples/i18n/it/lib/calcolatrice.rb @@ -3,9 +3,9 @@ def push(n) @args ||= [] @args << n end - + def add #@args[0] + @args[1] - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end -end \ No newline at end of file +end diff --git a/examples/i18n/ja/lib/calculator.rb b/examples/i18n/ja/lib/calculator.rb index 0598d3e627..ef1947f179 100644 --- a/examples/i18n/ja/lib/calculator.rb +++ b/examples/i18n/ja/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/ko/lib/calculator.rb b/examples/i18n/ko/lib/calculator.rb index 0598d3e627..ef1947f179 100644 --- a/examples/i18n/ko/lib/calculator.rb +++ b/examples/i18n/ko/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/lt/lib/calculator.rb b/examples/i18n/lt/lib/calculator.rb index e70f6a3858..a0f00f9ec5 100644 --- a/examples/i18n/lt/lib/calculator.rb +++ b/examples/i18n/lt/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/lv/lib/calculator.rb b/examples/i18n/lv/lib/calculator.rb index 0598d3e627..ef1947f179 100644 --- a/examples/i18n/lv/lib/calculator.rb +++ b/examples/i18n/lv/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/no/lib/kalkulator.rb b/examples/i18n/no/lib/kalkulator.rb index 081bf1c580..5ef7bdb059 100644 --- a/examples/i18n/no/lib/kalkulator.rb +++ b/examples/i18n/no/lib/kalkulator.rb @@ -6,6 +6,6 @@ def push(n) def add #@args[0] + @args[1] - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end end \ No newline at end of file diff --git a/examples/i18n/pl/lib/calculator.rb b/examples/i18n/pl/lib/calculator.rb index 2a3b2b5a24..b8ace2bb5d 100644 --- a/examples/i18n/pl/lib/calculator.rb +++ b/examples/i18n/pl/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def dodaj - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def podziel diff --git a/examples/i18n/pt/lib/calculadora.rb b/examples/i18n/pt/lib/calculadora.rb index 037f7de941..fceddab50a 100644 --- a/examples/i18n/pt/lib/calculadora.rb +++ b/examples/i18n/pt/lib/calculadora.rb @@ -3,7 +3,7 @@ def push(n) @args ||= [] @args << n end - + def soma @args.inject(0) {|n,sum| sum+n} end diff --git a/examples/i18n/ro/lib/calculator.rb b/examples/i18n/ro/lib/calculator.rb index cc6ce0e969..1c8d35d849 100644 --- a/examples/i18n/ro/lib/calculator.rb +++ b/examples/i18n/ro/lib/calculator.rb @@ -6,6 +6,6 @@ def push(n) def add #@args[0] + @args[1] - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end end diff --git a/examples/i18n/sk/lib/calculator.rb b/examples/i18n/sk/lib/calculator.rb index 0598d3e627..ef1947f179 100644 --- a/examples/i18n/sk/lib/calculator.rb +++ b/examples/i18n/sk/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/examples/i18n/sr-Cyrl/lib/calculator.rb b/examples/i18n/sr-Cyrl/lib/calculator.rb index 4a43d451e3..d232da7a2b 100644 --- a/examples/i18n/sr-Cyrl/lib/calculator.rb +++ b/examples/i18n/sr-Cyrl/lib/calculator.rb @@ -6,7 +6,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end end \ No newline at end of file diff --git a/examples/i18n/sr-Latn/lib/calculator.rb b/examples/i18n/sr-Latn/lib/calculator.rb index 4a43d451e3..d232da7a2b 100644 --- a/examples/i18n/sr-Latn/lib/calculator.rb +++ b/examples/i18n/sr-Latn/lib/calculator.rb @@ -6,7 +6,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end end \ No newline at end of file diff --git a/examples/i18n/sv/lib/kalkulator.rb b/examples/i18n/sv/lib/kalkulator.rb index 081bf1c580..5ef7bdb059 100644 --- a/examples/i18n/sv/lib/kalkulator.rb +++ b/examples/i18n/sv/lib/kalkulator.rb @@ -6,6 +6,6 @@ def push(n) def add #@args[0] + @args[1] - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end end \ No newline at end of file diff --git a/examples/i18n/tr/lib/hesap_makinesi.rb b/examples/i18n/tr/lib/hesap_makinesi.rb index 5e1359cda0..ad595b9e80 100644 --- a/examples/i18n/tr/lib/hesap_makinesi.rb +++ b/examples/i18n/tr/lib/hesap_makinesi.rb @@ -6,7 +6,7 @@ def push(n) end def topla - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def böl diff --git a/examples/i18n/zh-CN/lib/calculator.rb b/examples/i18n/zh-CN/lib/calculator.rb index 4e1ded9ea1..909e20e036 100644 --- a/examples/i18n/zh-CN/lib/calculator.rb +++ b/examples/i18n/zh-CN/lib/calculator.rb @@ -5,6 +5,6 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end end diff --git a/examples/i18n/zh-TW/lib/calculator.rb b/examples/i18n/zh-TW/lib/calculator.rb index 0598d3e627..ef1947f179 100644 --- a/examples/i18n/zh-TW/lib/calculator.rb +++ b/examples/i18n/zh-TW/lib/calculator.rb @@ -5,7 +5,7 @@ def push(n) end def add - @args.inject(0){|n,sum| sum+=n} + @args.inject(0){|n,sum| sum + n} end def divide diff --git a/features/lib/support/normalise_output.rb b/features/lib/support/normalise_output.rb index db625fda16..9911db7639 100644 --- a/features/lib/support/normalise_output.rb +++ b/features/lib/support/normalise_output.rb @@ -6,11 +6,11 @@ def all_stdout end def normalise_output(out) - out = out.gsub(/#{Dir.pwd}\/tmp\/aruba/, '.') # Remove absolute paths - out = out.gsub(/tmp\/aruba\//, '') # Fix aruba path - out = out.gsub(/^.*cucumber_process\.rb.*$\n/, '') - out = out.gsub(/^\d+m\d+\.\d+s$/, '0m0.012s') # Make duration predictable - out = out.gsub(/Coverage report generated .+$\n/, '') # Remove SimpleCov message + out.gsub(/#{Dir.pwd}\/tmp\/aruba/, '.') # Remove absolute paths + .gsub(/tmp\/aruba\//, '') # Fix aruba path + .gsub(/^.*cucumber_process\.rb.*$\n/, '') + .gsub(/^\d+m\d+\.\d+s$/, '0m0.012s') # Make duration predictable + .gsub(/Coverage report generated .+$\n/, '') # Remove SimpleCov message end def normalise_json(json) diff --git a/lib/cucumber/cli/profile_loader.rb b/lib/cucumber/cli/profile_loader.rb index 7c08617477..df9b458d93 100644 --- a/lib/cucumber/cli/profile_loader.rb +++ b/lib/cucumber/cli/profile_loader.rb @@ -62,13 +62,13 @@ def cucumber_yml require 'yaml' begin @cucumber_erb = ERB.new(IO.read(cucumber_file), nil, '%').result(binding) - rescue Exception => e + rescue Exception raise(YmlLoadError,"cucumber.yml was found, but could not be parsed with ERB. Please refer to cucumber's documentation on correct profile usage.\n#{$!.inspect}") end begin @cucumber_yml = YAML::load(@cucumber_erb) - rescue StandardError => e + rescue StandardError raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentation on correct profile usage.\n") end @@ -89,4 +89,3 @@ def cucumber_file end end end - diff --git a/lib/cucumber/formatter/console.rb b/lib/cucumber/formatter/console.rb index 4db9b43032..c8887e0625 100644 --- a/lib/cucumber/formatter/console.rb +++ b/lib/cucumber/formatter/console.rb @@ -105,7 +105,7 @@ def exception_message_string(e, indent) message = "#{e.message} (#{e.class})".dup.force_encoding("UTF-8") message = linebreaks(message, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i) - string = "#{message}\n#{e.backtrace.join("\n")}".indent(indent) + "#{message}\n#{e.backtrace.join("\n")}".indent(indent) end # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/10655 @@ -208,7 +208,6 @@ def print_profile_information end def do_print_profile_information(profiles) - profiles_sentence = '' profiles_sentence = profiles.size == 1 ? profiles.first : "#{profiles[0...-1].join(', ')} and #{profiles.last}" @@ -231,12 +230,12 @@ def hook?(test_step) end def element_messages(elements, status) - element_messages = elements.map do |element| - message = if status == :failed - exception_message_string(element.exception, 0) - else - linebreaks(element.backtrace_line, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i) - end + elements.map do |element| + if status == :failed + exception_message_string(element.exception, 0) + else + linebreaks(element.backtrace_line, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i) + end end end diff --git a/lib/cucumber/formatter/fail_fast.rb b/lib/cucumber/formatter/fail_fast.rb index 3d95b0ff9f..e00038af3e 100644 --- a/lib/cucumber/formatter/fail_fast.rb +++ b/lib/cucumber/formatter/fail_fast.rb @@ -9,7 +9,7 @@ class FailFast def initialize(configuration) configuration.on_event :test_case_finished do |event| - test_case, result = *event.attributes + _test_case, result = *event.attributes Cucumber.wants_to_quit = true unless result.ok?(configuration.strict?) end end diff --git a/lib/cucumber/formatter/html.rb b/lib/cucumber/formatter/html.rb index 3d005b6263..74e1ac2c0c 100644 --- a/lib/cucumber/formatter/html.rb +++ b/lib/cucumber/formatter/html.rb @@ -56,7 +56,7 @@ def embed_image(src, label) if @io.respond_to?(:path) and File.file?(src) out_dir = Pathname.new(File.dirname(File.absolute_path(@io.path))) src = Pathname.new(File.absolute_path(src)).relative_path_from(out_dir) - end + end @builder.span(:class => 'embed') do |pre| pre << %{#{label}
  } @@ -297,7 +297,7 @@ def after_step_result(keyword, step_match, multiline_arg, status, exception, sou end if status == :undefined @builder.pre do |pre| - # TODO: snippet text should be an event sent to the formatter so we don't + # TODO: snippet text should be an event sent to the formatter so we don't # have this couping to the runtime. pre << @runtime.snippet_text(keyword,step_match.instance_variable_get("@name") || '', @step.multiline_arg) end @@ -638,7 +638,13 @@ def outline_step?(step) class SnippetExtractor #:nodoc: class NullConverter; def convert(code, pre); code; end; end #:nodoc: - begin; require 'syntax/convertors/html'; @@converter = Syntax::Convertors::HTML.for_syntax "ruby"; rescue LoadError => e; @@converter = NullConverter.new; end + + begin + require 'syntax/convertors/html' + @@converter = Syntax::Convertors::HTML.for_syntax "ruby" + rescue LoadError + @@converter = NullConverter.new + end def snippet(error) raw_code, line = snippet_for(error[0]) diff --git a/lib/cucumber/formatter/json.rb b/lib/cucumber/formatter/json.rb index 23f8e10fe3..d781d290d7 100644 --- a/lib/cucumber/formatter/json.rb +++ b/lib/cucumber/formatter/json.rb @@ -66,7 +66,7 @@ def on_test_step_finished(event) end def on_test_case_finished(event) - test_case, result = *event.attributes + _test_case, result = *event.attributes result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter) add_failed_around_hook(result) if result.failed? && !@any_step_failed end diff --git a/lib/cucumber/formatter/legacy_api/adapter.rb b/lib/cucumber/formatter/legacy_api/adapter.rb index 75e78e7136..7b0b62acae 100644 --- a/lib/cucumber/formatter/legacy_api/adapter.rb +++ b/lib/cucumber/formatter/legacy_api/adapter.rb @@ -359,7 +359,7 @@ def print_step if @failed_hidden_background_step indent = Indent.new(@child.node) - step_invocation = @failed_hidden_background_step.build_step_invocation(indent, matches, config, messages = [], embeddings = []) + step_invocation = @failed_hidden_background_step.build_step_invocation(indent, matches, config, [], []) @child.step_invocation(step_invocation, @failed_hidden_background_step) @failed_hidden_background_step = nil end @@ -592,7 +592,7 @@ def before end def step_invocation(step_invocation, source) - node, result = source.step, source.step_result + _node, result = source.step, source.step_result @last_step_result = result @child.step_invocation(step_invocation, source) end @@ -643,7 +643,7 @@ def scenario_outline(node, &descend) def outline_step(step) step_match = NoStepMatch.new(step, step.name) step_invocation = LegacyResultBuilder.new(Core::Test::Result::Skipped.new). - step_invocation(step_match, step, indent, background = nil, configuration, messages = [], embeddings = []) + step_invocation(step_match, step, indent, nil, configuration, [], []) steps_printer.step_invocation step_invocation end diff --git a/lib/cucumber/formatter/progress.rb b/lib/cucumber/formatter/progress.rb index 610197144a..efbba72e13 100644 --- a/lib/cucumber/formatter/progress.rb +++ b/lib/cucumber/formatter/progress.rb @@ -86,7 +86,7 @@ def print_summary do_print_snippets(snippet_text_proc) if config.snippets? && summary.test_steps.total(:undefined) > 0 return unless config.wip? messages = @passed_test_cases.map do |test_case| - message = linebreaks("#{test_case.location.on_line(test_case.location.line)}:in `#{test_case.name}'", ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i) + linebreaks("#{test_case.location.on_line(test_case.location.line)}:in `#{test_case.name}'", ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i) end do_print_passing_wip(messages) end diff --git a/spec/cucumber/formatter/spec_helper.rb b/spec/cucumber/formatter/spec_helper.rb index 0265bf9309..41813681a4 100644 --- a/spec/cucumber/formatter/spec_helper.rb +++ b/spec/cucumber/formatter/spec_helper.rb @@ -69,7 +69,7 @@ def event_bus def define_steps return unless step_defs = self.class.step_defs - rb = runtime.support_code.ruby + runtime.support_code.ruby dsl = Object.new dsl.extend RbSupport::RbDsl dsl.instance_exec &step_defs diff --git a/spec/cucumber/rb_support/rb_step_definition_spec.rb b/spec/cucumber/rb_support/rb_step_definition_spec.rb index 26b16a482c..9438f5a20e 100644 --- a/spec/cucumber/rb_support/rb_step_definition_spec.rb +++ b/spec/cucumber/rb_support/rb_step_definition_spec.rb @@ -42,7 +42,6 @@ def step_match(text) it "allows calling of other steps with inline arg" do dsl.Given(/Outside/) do - location = Core::Ast::Location.new(__FILE__, __LINE__) step "Inside", table([['inside']]) end dsl.Given(/Inside/) do |t| diff --git a/spec/cucumber/step_match_search_spec.rb b/spec/cucumber/step_match_search_spec.rb index 2991cf2628..112165afca 100644 --- a/spec/cucumber/step_match_search_spec.rb +++ b/spec/cucumber/step_match_search_spec.rb @@ -89,22 +89,22 @@ module Cucumber end it "picks right step definition when an equal number of capture groups" do - right = dsl.Given(/Three (.*) mice/) {|disability|} - wrong = dsl.Given(/Three (.*)/) {|animal|} + right = dsl.Given(/Three (.*) mice/) {|disability|} + _wrong = dsl.Given(/Three (.*)/) {|animal|} expect(search.call("Three blind mice").first.step_definition).to eq right end it "picks right step definition when an unequal number of capture groups" do - right = dsl.Given(/Three (.*) mice ran (.*)/) {|disability|} - wrong = dsl.Given(/Three (.*)/) {|animal|} + right = dsl.Given(/Three (.*) mice ran (.*)/) {|disability|} + _wrong = dsl.Given(/Three (.*)/) {|animal|} expect(search.call("Three blind mice ran far").first.step_definition).to eq right end it "picks most specific step definition when an unequal number of capture groups" do - general = dsl.Given(/Three (.*) mice ran (.*)/) {|disability|} - specific = dsl.Given(/Three blind mice ran far/) do; end + _general = dsl.Given(/Three (.*) mice ran (.*)/) {|disability|} + _specific = dsl.Given(/Three blind mice ran far/) do; end more_specific = dsl.Given(/^Three blind mice ran far$/) do; end expect(search.call("Three blind mice ran far").first.step_definition).to eq more_specific @@ -120,4 +120,3 @@ module Cucumber end end end - From e79aadd2b6b6606762755de363a8b6d3ca8c753e Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Fri, 23 Sep 2016 11:41:05 +0100 Subject: [PATCH 06/13] Update history --- History.md | 1 + 1 file changed, 1 insertion(+) diff --git a/History.md b/History.md index 0f7546614c..0302b40ef0 100644 --- a/History.md +++ b/History.md @@ -26,6 +26,7 @@ * Fix the rubocop violation 'Lint/AmbiguousRegexpLiteral' ([1025](https://github.com/cucumber/cucumber-ruby/pull/1025) @pmatsinopoulos) * Fix rubocop violations ([#1024](https://github.com/cucumber/cucumber-ruby/pull/1024) @madundead) * Fix style violations ([#1023](https://github.com/cucumber/cucumber-ruby/pull/1023) @nodo) +* fix Lint/UselessAssignment ([1029](https://github.com/cucumber/cucumber-ruby/pull/1029) @hotovson) ## [v2.4.0](https://github.com/cucumber/cucumber-ruby/compare/v2.3.3...v2.4.0) From 475bcd07d8ad7a383f969db0f593808b58d876e6 Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Fri, 23 Sep 2016 12:47:31 +0100 Subject: [PATCH 07/13] Update link to contributors gitter channel --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b1339fb92f..c6b3b0723b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ The rest of this document is a guide for those maintaining Cucumber, and others ## Talking with other devs -You can chat with the core team on https://gitter.im/cucumber/cucumber. We try to have office hours on Fridays. +You can chat with the core team on https://gitter.im/cucumber/contributors. We try to have office hours on Fridays. ## Installing your own gems From ceb80e13d794fb94b7fa74ec4f172ba7124ce751 Mon Sep 17 00:00:00 2001 From: hotovson Date: Sat, 24 Sep 2016 21:01:42 +0200 Subject: [PATCH 08/13] fix Lint/EndAlignment --- .rubocop_todo.yml | 7 ------- gem_tasks/cucumber.rake | 20 ++++++++++---------- gem_tasks/environment.rake | 6 +----- lib/cucumber/cli/main.rb | 10 +++++----- lib/cucumber/formatter/console.rb | 10 +++++----- lib/cucumber/formatter/legacy_api/ast.rb | 8 ++++---- lib/cucumber/step_match.rb | 12 ++++++------ 7 files changed, 31 insertions(+), 42 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a22aff30c2..6fa552819a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -37,13 +37,6 @@ Lint/DuplicateMethods: Exclude: - 'lib/cucumber/multiline_argument.rb' -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect. -# SupportedStyles: keyword, variable, start_of_line -Lint/EndAlignment: - Enabled: false - # Offense count: 2 Lint/Eval: Exclude: diff --git a/gem_tasks/cucumber.rake b/gem_tasks/cucumber.rake index 7be4670189..599b7373d4 100644 --- a/gem_tasks/cucumber.rake +++ b/gem_tasks/cucumber.rake @@ -5,16 +5,16 @@ require 'cucumber/platform' class Cucumber::Rake::Task def set_profile_for_current_ruby self.profile = if Cucumber::JRUBY - Cucumber::WINDOWS ? 'jruby_win' : 'jruby' - elsif Cucumber::WINDOWS_MRI - 'windows_mri' - elsif Cucumber::RUBY_1_9 - 'ruby_1_9' - elsif Cucumber::RUBY_2_0 - 'ruby_2_0' - elsif Cucumber::RUBY_2_1 - 'ruby_2_1' - end + Cucumber::WINDOWS ? 'jruby_win' : 'jruby' + elsif Cucumber::WINDOWS_MRI + 'windows_mri' + elsif Cucumber::RUBY_1_9 + 'ruby_1_9' + elsif Cucumber::RUBY_2_0 + 'ruby_2_0' + elsif Cucumber::RUBY_2_1 + 'ruby_2_1' + end end end diff --git a/gem_tasks/environment.rake b/gem_tasks/environment.rake index 122a7f2774..334d543158 100644 --- a/gem_tasks/environment.rake +++ b/gem_tasks/environment.rake @@ -1,8 +1,4 @@ # frozen_string_literal: true task :ruby_env do - RUBY_APP = if RUBY_PLATFORM =~ /java/ - "jruby" - else - "ruby" - end unless defined? RUBY_APP + RUBY_APP ||= RUBY_PLATFORM =~ /java/ ? 'jruby' : 'ruby' end diff --git a/lib/cucumber/cli/main.rb b/lib/cucumber/cli/main.rb index b36bf96a93..bababe97eb 100644 --- a/lib/cucumber/cli/main.rb +++ b/lib/cucumber/cli/main.rb @@ -24,11 +24,11 @@ def execute!(existing_runtime = nil) trap_interrupt runtime = if existing_runtime - existing_runtime.configure(configuration) - existing_runtime - else - Runtime.new(configuration) - end + existing_runtime.configure(configuration) + existing_runtime + else + Runtime.new(configuration) + end runtime.run! if Cucumber.wants_to_quit diff --git a/lib/cucumber/formatter/console.rb b/lib/cucumber/formatter/console.rb index c8887e0625..70748220ab 100644 --- a/lib/cucumber/formatter/console.rb +++ b/lib/cucumber/formatter/console.rb @@ -32,11 +32,11 @@ module Console def format_step(keyword, step_match, status, source_indent) comment = if source_indent - c = ('# ' + step_match.location.to_s).indent(source_indent) - format_string(c, :comment) - else - '' - end + c = ('# ' + step_match.location.to_s).indent(source_indent) + format_string(c, :comment) + else + '' + end format = format_for(status, :param) line = keyword + step_match.format_args(format) + comment diff --git a/lib/cucumber/formatter/legacy_api/ast.rb b/lib/cucumber/formatter/legacy_api/ast.rb index 029aaeaf4e..55c0ae1c5e 100644 --- a/lib/cucumber/formatter/legacy_api/ast.rb +++ b/lib/cucumber/formatter/legacy_api/ast.rb @@ -120,10 +120,10 @@ def accept(formatter) def step_result_attributes legacy_multiline_arg = if multiline_arg.kind_of?(Core::Ast::EmptyMultilineArgument) - nil - else - step.multiline_arg - end + nil + else + step.multiline_arg + end [keyword, step_match, legacy_multiline_arg, status, exception, source_indent, background, file_colon_line] end diff --git a/lib/cucumber/step_match.rb b/lib/cucumber/step_match.rb index 24c3b5974d..0cd7c26569 100644 --- a/lib/cucumber/step_match.rb +++ b/lib/cucumber/step_match.rb @@ -70,12 +70,12 @@ def replace_arguments(string, step_arguments, format, &proc) next if step_argument.offset.nil? || step_argument.offset < past_offset replacement = if block_given? - proc.call(step_argument.val) - elsif Proc === format - format.call(step_argument.val) - else - format % step_argument.val - end + proc.call(step_argument.val) + elsif Proc === format + format.call(step_argument.val) + else + format % step_argument.val + end s[step_argument.offset + offset, step_argument.val.length] = replacement offset += replacement.unpack('U*').length - step_argument.val.unpack('U*').length From 4215c9d868f8368089e59487c2e38172ccb752c5 Mon Sep 17 00:00:00 2001 From: hotovson Date: Sat, 24 Sep 2016 23:06:26 +0200 Subject: [PATCH 09/13] fix Lint/NonLocalExitFromIterator --- .rubocop_todo.yml | 5 ----- lib/autotest/cucumber_mixin.rb | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a22aff30c2..5c981a7e23 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -72,11 +72,6 @@ Lint/NestedMethodDefinition: Exclude: - 'lib/cucumber/formatter/ansicolor.rb' -# Offense count: 1 -Lint/NonLocalExitFromIterator: - Exclude: - - 'lib/autotest/cucumber_mixin.rb' - # Offense count: 7 Lint/RescueException: Exclude: diff --git a/lib/autotest/cucumber_mixin.rb b/lib/autotest/cucumber_mixin.rb index 4084b80b7c..408baedb37 100644 --- a/lib/autotest/cucumber_mixin.rb +++ b/lib/autotest/cucumber_mixin.rb @@ -71,7 +71,7 @@ def run_features hook :run_features Tempfile.open('autotest-cucumber') do |dirty_features_file| cmd = self.make_cucumber_cmd(self.features_to_run, dirty_features_file.path) - return if cmd.empty? + break if cmd.empty? puts cmd unless $q old_sync = $stdout.sync $stdout.sync = true From a7b6e6a922bc07925e6ceab63b47429ee4c56cb8 Mon Sep 17 00:00:00 2001 From: Andrea Nodari Date: Sun, 25 Sep 2016 18:16:44 +0100 Subject: [PATCH 10/13] Update history --- History.md | 1 + 1 file changed, 1 insertion(+) diff --git a/History.md b/History.md index 0302b40ef0..b7802db123 100644 --- a/History.md +++ b/History.md @@ -27,6 +27,7 @@ * Fix rubocop violations ([#1024](https://github.com/cucumber/cucumber-ruby/pull/1024) @madundead) * Fix style violations ([#1023](https://github.com/cucumber/cucumber-ruby/pull/1023) @nodo) * fix Lint/UselessAssignment ([1029](https://github.com/cucumber/cucumber-ruby/pull/1029) @hotovson) +* fix Lint/EndAlignment ([#1032](https://github.com/cucumber/cucumber-ruby/pull/1032) @hotovson) ## [v2.4.0](https://github.com/cucumber/cucumber-ruby/compare/v2.3.3...v2.4.0) From 38799e6209aa73964550e94f90a29f071da38936 Mon Sep 17 00:00:00 2001 From: Andrea Nodari Date: Mon, 26 Sep 2016 14:11:55 +0100 Subject: [PATCH 11/13] Update history --- History.md | 1 + 1 file changed, 1 insertion(+) diff --git a/History.md b/History.md index b7802db123..44cb702991 100644 --- a/History.md +++ b/History.md @@ -28,6 +28,7 @@ * Fix style violations ([#1023](https://github.com/cucumber/cucumber-ruby/pull/1023) @nodo) * fix Lint/UselessAssignment ([1029](https://github.com/cucumber/cucumber-ruby/pull/1029) @hotovson) * fix Lint/EndAlignment ([#1032](https://github.com/cucumber/cucumber-ruby/pull/1032) @hotovson) +* fix Lint/NonLocalExitFromIterator ([#1037](https://github.com/cucumber/cucumber-ruby/pull/1037) @hotovson) ## [v2.4.0](https://github.com/cucumber/cucumber-ruby/compare/v2.3.3...v2.4.0) From 322dd159f2ef37f54f824da73126d346c79c829d Mon Sep 17 00:00:00 2001 From: hotovson Date: Sat, 24 Sep 2016 23:01:06 +0200 Subject: [PATCH 12/13] fix Lint/UselessAccessModifier --- .rubocop_todo.yml | 5 ----- lib/cucumber/multiline_argument/data_table.rb | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 564630d11b..4fa1bcad72 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -106,11 +106,6 @@ Lint/UnusedBlockArgument: Lint/UnusedMethodArgument: Enabled: false -# Offense count: 1 -Lint/UselessAccessModifier: - Exclude: - - 'lib/cucumber/multiline_argument/data_table.rb' - # Offense count: 60 Metrics/AbcSize: Max: 99 diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index c200e69c54..dd638c0517 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -494,11 +494,10 @@ def to_json(*args) raw.to_json(*args) end - private - TO_S_PREFIXES = Hash.new(' ') TO_S_PREFIXES[:comment] = '(+) ' TO_S_PREFIXES[:undefined] = '(-) ' + private_constant :TO_S_PREFIXES protected From 945c13a41f0f33d5aba42a02c5cedb1cf3c124bd Mon Sep 17 00:00:00 2001 From: Andrea Nodari Date: Tue, 27 Sep 2016 14:34:02 +0100 Subject: [PATCH 13/13] Update history --- History.md | 1 + 1 file changed, 1 insertion(+) diff --git a/History.md b/History.md index 44cb702991..db9c03e820 100644 --- a/History.md +++ b/History.md @@ -29,6 +29,7 @@ * fix Lint/UselessAssignment ([1029](https://github.com/cucumber/cucumber-ruby/pull/1029) @hotovson) * fix Lint/EndAlignment ([#1032](https://github.com/cucumber/cucumber-ruby/pull/1032) @hotovson) * fix Lint/NonLocalExitFromIterator ([#1037](https://github.com/cucumber/cucumber-ruby/pull/1037) @hotovson) +* fix Lint/UselessAccessModifier ([#1036](https://github.com/cucumber/cucumber-ruby/pull/1036) @hotovson) ## [v2.4.0](https://github.com/cucumber/cucumber-ruby/compare/v2.3.3...v2.4.0)