From dab32a743dd5861b8185a0aa8fccb54b2682e502 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Mon, 2 Oct 2023 15:06:15 +0100 Subject: [PATCH 1/9] Pin rubocop gems and 0.x gems more aggressively --- cucumber.gemspec | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cucumber.gemspec b/cucumber.gemspec index 822abfc40..a8e9e2b97 100644 --- a/cucumber.gemspec +++ b/cucumber.gemspec @@ -39,12 +39,12 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry', '~> 0.14', '>= 0.14.1' s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' s.add_development_dependency 'rspec', '~> 3.12', '>= 3.12.0' - s.add_development_dependency 'rubocop', '~> 1.56', '>= 1.56.2' - s.add_development_dependency 'rubocop-capybara', '~> 2.18', '>= 2.18.0' - s.add_development_dependency 'rubocop-packaging', '~> 0.5', '>= 0.5.2' - s.add_development_dependency 'rubocop-rake', '~> 0.6', '>= 0.6.0' - s.add_development_dependency 'rubocop-rspec', '~> 2.23', '>= 2.23.2' - s.add_development_dependency 'simplecov', '~> 0.22', '>= 0.22.0' + s.add_development_dependency 'rubocop', '~> 1.56.2' + s.add_development_dependency 'rubocop-capybara', '~> 2.18.0' + s.add_development_dependency 'rubocop-packaging', '~> 0.5.2' + s.add_development_dependency 'rubocop-rake', '~> 0.6.0' + s.add_development_dependency 'rubocop-rspec', '~> 2.23.2' + s.add_development_dependency 'simplecov', '~> 0.22.0' s.add_development_dependency 'syntax', '~> 1.2', '>= 1.2.2' s.add_development_dependency 'test-unit', '~> 3.6', '>= 3.6.1' s.add_development_dependency 'webrick', '~> 1.8', '>= 1.8.1' From 5ee55ac7dfb3c1bad4b5812d57af7e47b8071b3f Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Mon, 2 Oct 2023 15:09:03 +0100 Subject: [PATCH 2/9] Update rubocop sub-gems --- cucumber.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cucumber.gemspec b/cucumber.gemspec index a8e9e2b97..0e6787c04 100644 --- a/cucumber.gemspec +++ b/cucumber.gemspec @@ -39,11 +39,11 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry', '~> 0.14', '>= 0.14.1' s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' s.add_development_dependency 'rspec', '~> 3.12', '>= 3.12.0' - s.add_development_dependency 'rubocop', '~> 1.56.2' - s.add_development_dependency 'rubocop-capybara', '~> 2.18.0' + s.add_development_dependency 'rubocop', '~> 1.56.4' + s.add_development_dependency 'rubocop-capybara', '~> 2.19.0' s.add_development_dependency 'rubocop-packaging', '~> 0.5.2' s.add_development_dependency 'rubocop-rake', '~> 0.6.0' - s.add_development_dependency 'rubocop-rspec', '~> 2.23.2' + s.add_development_dependency 'rubocop-rspec', '~> 2.24.1' s.add_development_dependency 'simplecov', '~> 0.22.0' s.add_development_dependency 'syntax', '~> 1.2', '>= 1.2.2' s.add_development_dependency 'test-unit', '~> 3.6', '>= 3.6.1' From 0eebaf64e434ca3c1606b16140fe70272ac089de Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Mon, 2 Oct 2023 15:11:49 +0100 Subject: [PATCH 3/9] Remove redundant block / length based configs now rubocop-rspec and rubocop are updated --- .rubocop.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index da03ea664..868940e32 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -52,14 +52,6 @@ Metrics/AbcSize: - spec/cucumber/formatter/http_io_spec.rb - lib/cucumber/glue/proto_world.rb -# TODO: [LH] - This needs a re-review. I think we can pretty much delete / phase this out with incremental updates -Metrics/BlockLength: - CountComments: false - Exclude: - - './cucumber.gemspec' - - './spec/**/*' - - 'cck/spec/**/*' - # TODO: [LH] - This definitely needs a partial fix / reduction. Even if only an interim one that pushes some stuff Metrics/ClassLength: Max: 375 @@ -73,7 +65,6 @@ Metrics/ModuleLength: Max: 135 Exclude: - './spec/**/*' - - 'cck/spec/**/*' # TODO: Manually added! - be careful with regenning the file - this needs a fix - lib/cucumber/formatter/console.rb @@ -88,8 +79,7 @@ Metrics/MethodLength: - spec/cucumber/formatter/http_io_spec.rb - lib/cucumber/glue/proto_world.rb -# Rubocop doesn't like method names in other languages but as Cucumber supports -# languages, this cop needs to be disabled. +# Rubocop doesn't like method names in other languages but as Cucumber supports multiple languages, this cop needs to be disabled. Naming/AsciiIdentifiers: Enabled: false From 84d0ad4e9ae81ca2d8827ce6108e5d6dc44a86dd Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Mon, 2 Oct 2023 15:23:37 +0100 Subject: [PATCH 4/9] Partially fix up small param name cop --- .rubocop.yml | 10 ++++------ examples/i18n/ar/lib/calculator.rb | 11 +++++++---- examples/i18n/bg/lib/calculator.rb | 2 +- examples/i18n/ca/lib/calculadora.rb | 13 ++++++++----- examples/i18n/cs/lib/calculator.rb | 13 ++++++++----- examples/i18n/da/lib/lommeregner.rb | 11 +++++++---- examples/i18n/de/lib/calculator.rb | 13 ++++++++----- examples/i18n/el/lib/calculator.rb | 13 ++++++++----- examples/i18n/en/lib/calculator.rb | 13 ++++++++----- examples/i18n/eo/lib/calculator.rb | 13 ++++++++----- examples/i18n/es/lib/calculador.rb | 13 ++++++++----- examples/i18n/et/lib/kalkulaator.rb | 13 ++++++++----- examples/i18n/fi/lib/laskin.rb | 13 ++++++++----- examples/i18n/fr/lib/calculatrice.rb | 11 +++++++---- examples/i18n/he/lib/calculator.rb | 13 ++++++++----- examples/i18n/hi/lib/calculator.rb | 13 ++++++++----- examples/i18n/ht/lib/kalkilatris.rb | 13 ++++++++----- examples/i18n/hu/lib/calculator.rb | 13 ++++++++----- examples/i18n/id/lib/calculator.rb | 13 ++++++++----- examples/i18n/it/lib/calcolatrice.rb | 11 +++++++---- examples/i18n/ja/lib/calculator.rb | 13 ++++++++----- examples/i18n/ko/lib/calculator.rb | 13 ++++++++----- examples/i18n/lt/lib/calculator.rb | 13 ++++++++----- examples/i18n/lv/lib/calculator.rb | 13 ++++++++----- examples/i18n/no/lib/kalkulator.rb | 11 +++++++---- examples/i18n/pl/lib/calculator.rb | 13 ++++++++----- examples/i18n/pt/lib/calculadora.rb | 11 +++++++---- examples/i18n/ro/lib/calculator.rb | 11 +++++++---- examples/i18n/ru/lib/calculator.rb | 6 +++--- examples/i18n/sk/lib/calculator.rb | 13 ++++++++----- examples/i18n/sr-Cyrl/lib/calculator.rb | 11 +++++++---- examples/i18n/sr-Latn/lib/calculator.rb | 11 +++++++---- examples/i18n/sv/lib/kalkulator.rb | 11 +++++++---- examples/i18n/tr/lib/hesap_makinesi.rb | 13 ++++++++----- examples/i18n/uk/lib/calculator.rb | 6 +++--- examples/i18n/uz/lib/calculator.rb | 6 +++--- examples/i18n/zh-CN/lib/calculator.rb | 11 +++++++---- examples/i18n/zh-TW/lib/calculator.rb | 13 ++++++++----- 38 files changed, 267 insertions(+), 170 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 868940e32..b465ce6ac 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -89,14 +89,12 @@ Naming/MethodName: Exclude: - 'examples/i18n/ar/lib/calculator.rb' - 'examples/i18n/he/lib/calculator.rb' - - 'examples/i18n/he/lib/calculator.rb' - - 'examples/i18n/tr/lib/hesap_makinesi.rb' - 'lib/cucumber/glue/dsl.rb' -# In most cases, being descriptive with parameter names helps a reader understand -# what the variable is for. In some cases, shorter names are sufficient. -Naming/MethodParameterName: - AllowedNames: _, e, n, v, id, io, gh, pr +## In most cases, being descriptive with parameter names helps a reader understand +## what the variable is for. In some cases, shorter names are sufficient. +#Naming/MethodParameterName: +# AllowedNames: _, e, n, v, id, io, gh, pr # Reviewed: these offenses look false as the variables are in cyrillic Naming/VariableName: diff --git a/examples/i18n/ar/lib/calculator.rb b/examples/i18n/ar/lib/calculator.rb index 7065cb25a..071a2e0a1 100644 --- a/examples/i18n/ar/lib/calculator.rb +++ b/examples/i18n/ar/lib/calculator.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def جمع - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end end diff --git a/examples/i18n/bg/lib/calculator.rb b/examples/i18n/bg/lib/calculator.rb index add97dc6a..59567a71c 100644 --- a/examples/i18n/bg/lib/calculator.rb +++ b/examples/i18n/bg/lib/calculator.rb @@ -6,7 +6,7 @@ def initialize end def push(arg) - @stack.push arg + @stack.push(arg) end def result diff --git a/examples/i18n/ca/lib/calculadora.rb b/examples/i18n/ca/lib/calculadora.rb index 2ed377169..0dc39f841 100644 --- a/examples/i18n/ca/lib/calculadora.rb +++ b/examples/i18n/ca/lib/calculadora.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculadora - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/cs/lib/calculator.rb b/examples/i18n/cs/lib/calculator.rb index c8672e7b6..b85f6ed29 100644 --- a/examples/i18n/cs/lib/calculator.rb +++ b/examples/i18n/cs/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @args[1] end end diff --git a/examples/i18n/da/lib/lommeregner.rb b/examples/i18n/da/lib/lommeregner.rb index a8ffb70eb..12f930130 100644 --- a/examples/i18n/da/lib/lommeregner.rb +++ b/examples/i18n/da/lib/lommeregner.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Lommeregner - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.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 c8672e7b6..9a111bdee 100644 --- a/examples/i18n/de/lib/calculator.rb +++ b/examples/i18n/de/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/el/lib/calculator.rb b/examples/i18n/el/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/el/lib/calculator.rb +++ b/examples/i18n/el/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/en/lib/calculator.rb b/examples/i18n/en/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/en/lib/calculator.rb +++ b/examples/i18n/en/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/eo/lib/calculator.rb b/examples/i18n/eo/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/eo/lib/calculator.rb +++ b/examples/i18n/eo/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/es/lib/calculador.rb b/examples/i18n/es/lib/calculador.rb index 0e7e0a9f3..e367811e7 100644 --- a/examples/i18n/es/lib/calculador.rb +++ b/examples/i18n/es/lib/calculador.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculador - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/et/lib/kalkulaator.rb b/examples/i18n/et/lib/kalkulaator.rb index 69587953e..8c6d4c993 100644 --- a/examples/i18n/et/lib/kalkulaator.rb +++ b/examples/i18n/et/lib/kalkulaator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Kalkulaator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def liida - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def jaga - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/fi/lib/laskin.rb b/examples/i18n/fi/lib/laskin.rb index 0a1a6ebdc..dc7333f2a 100644 --- a/examples/i18n/fi/lib/laskin.rb +++ b/examples/i18n/fi/lib/laskin.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Laskin - def pinoa(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def summaa - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def jaa - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/fr/lib/calculatrice.rb b/examples/i18n/fr/lib/calculatrice.rb index 55f4b1f73..b79089bce 100644 --- a/examples/i18n/fr/lib/calculatrice.rb +++ b/examples/i18n/fr/lib/calculatrice.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Calculatrice - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def additionner - @args.inject(0) { |n, sum| sum + n } + @stack.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 f7cc948b9..e4e70b27f 100644 --- a/examples/i18n/he/lib/calculator.rb +++ b/examples/i18n/he/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def חבר - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def חלק - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/hi/lib/calculator.rb b/examples/i18n/hi/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/hi/lib/calculator.rb +++ b/examples/i18n/hi/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/ht/lib/kalkilatris.rb b/examples/i18n/ht/lib/kalkilatris.rb index e8771a1c2..07b983660 100644 --- a/examples/i18n/ht/lib/kalkilatris.rb +++ b/examples/i18n/ht/lib/kalkilatris.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Kalkilatris - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def ajoute - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divize - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/hu/lib/calculator.rb b/examples/i18n/hu/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/hu/lib/calculator.rb +++ b/examples/i18n/hu/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/id/lib/calculator.rb b/examples/i18n/id/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/id/lib/calculator.rb +++ b/examples/i18n/id/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/it/lib/calcolatrice.rb b/examples/i18n/it/lib/calcolatrice.rb index a4e0ad3b0..60dd71cd5 100644 --- a/examples/i18n/it/lib/calcolatrice.rb +++ b/examples/i18n/it/lib/calcolatrice.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Calcolatrice - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end end diff --git a/examples/i18n/ja/lib/calculator.rb b/examples/i18n/ja/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/ja/lib/calculator.rb +++ b/examples/i18n/ja/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/ko/lib/calculator.rb b/examples/i18n/ko/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/ko/lib/calculator.rb +++ b/examples/i18n/ko/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/lt/lib/calculator.rb b/examples/i18n/lt/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/lt/lib/calculator.rb +++ b/examples/i18n/lt/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/lv/lib/calculator.rb b/examples/i18n/lv/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/lv/lib/calculator.rb +++ b/examples/i18n/lv/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/no/lib/kalkulator.rb b/examples/i18n/no/lib/kalkulator.rb index 298fe9cd5..40926cb99 100644 --- a/examples/i18n/no/lib/kalkulator.rb +++ b/examples/i18n/no/lib/kalkulator.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Kalkulator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end end diff --git a/examples/i18n/pl/lib/calculator.rb b/examples/i18n/pl/lib/calculator.rb index e1b34d5f2..9cbb23447 100644 --- a/examples/i18n/pl/lib/calculator.rb +++ b/examples/i18n/pl/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def dodaj - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def podziel - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/pt/lib/calculadora.rb b/examples/i18n/pt/lib/calculadora.rb index 30fcbf4d5..ba909a127 100644 --- a/examples/i18n/pt/lib/calculadora.rb +++ b/examples/i18n/pt/lib/calculadora.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Calculadora - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def soma - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end end diff --git a/examples/i18n/ro/lib/calculator.rb b/examples/i18n/ro/lib/calculator.rb index 086ad16c5..e592772e8 100644 --- a/examples/i18n/ro/lib/calculator.rb +++ b/examples/i18n/ro/lib/calculator.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end end diff --git a/examples/i18n/ru/lib/calculator.rb b/examples/i18n/ru/lib/calculator.rb index add97dc6a..8090357f3 100644 --- a/examples/i18n/ru/lib/calculator.rb +++ b/examples/i18n/ru/lib/calculator.rb @@ -6,7 +6,7 @@ def initialize end def push(arg) - @stack.push arg + @stack.push(arg) end def result @@ -17,13 +17,13 @@ def + number_1 = @stack.pop number_2 = @stack.pop - @stack.push number_1 + number_2 + @stack.push(number_1 + number_2) end def / divisor = @stack.pop dividend = @stack.pop - @stack.push dividend / divisor + @stack.push(dividend / divisor) end end diff --git a/examples/i18n/sk/lib/calculator.rb b/examples/i18n/sk/lib/calculator.rb index c8672e7b6..9a111bdee 100644 --- a/examples/i18n/sk/lib/calculator.rb +++ b/examples/i18n/sk/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/sr-Cyrl/lib/calculator.rb b/examples/i18n/sr-Cyrl/lib/calculator.rb index 086ad16c5..e592772e8 100644 --- a/examples/i18n/sr-Cyrl/lib/calculator.rb +++ b/examples/i18n/sr-Cyrl/lib/calculator.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end end diff --git a/examples/i18n/sr-Latn/lib/calculator.rb b/examples/i18n/sr-Latn/lib/calculator.rb index 086ad16c5..e592772e8 100644 --- a/examples/i18n/sr-Latn/lib/calculator.rb +++ b/examples/i18n/sr-Latn/lib/calculator.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end end diff --git a/examples/i18n/sv/lib/kalkulator.rb b/examples/i18n/sv/lib/kalkulator.rb index 298fe9cd5..40926cb99 100644 --- a/examples/i18n/sv/lib/kalkulator.rb +++ b/examples/i18n/sv/lib/kalkulator.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Kalkulator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end end diff --git a/examples/i18n/tr/lib/hesap_makinesi.rb b/examples/i18n/tr/lib/hesap_makinesi.rb index b549f5e71..849d50699 100644 --- a/examples/i18n/tr/lib/hesap_makinesi.rb +++ b/examples/i18n/tr/lib/hesap_makinesi.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class HesapMakinesi - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def topla - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def böl - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end diff --git a/examples/i18n/uk/lib/calculator.rb b/examples/i18n/uk/lib/calculator.rb index add97dc6a..8090357f3 100644 --- a/examples/i18n/uk/lib/calculator.rb +++ b/examples/i18n/uk/lib/calculator.rb @@ -6,7 +6,7 @@ def initialize end def push(arg) - @stack.push arg + @stack.push(arg) end def result @@ -17,13 +17,13 @@ def + number_1 = @stack.pop number_2 = @stack.pop - @stack.push number_1 + number_2 + @stack.push(number_1 + number_2) end def / divisor = @stack.pop dividend = @stack.pop - @stack.push dividend / divisor + @stack.push(dividend / divisor) end end diff --git a/examples/i18n/uz/lib/calculator.rb b/examples/i18n/uz/lib/calculator.rb index add97dc6a..8090357f3 100644 --- a/examples/i18n/uz/lib/calculator.rb +++ b/examples/i18n/uz/lib/calculator.rb @@ -6,7 +6,7 @@ def initialize end def push(arg) - @stack.push arg + @stack.push(arg) end def result @@ -17,13 +17,13 @@ def + number_1 = @stack.pop number_2 = @stack.pop - @stack.push number_1 + number_2 + @stack.push(number_1 + number_2) end def / divisor = @stack.pop dividend = @stack.pop - @stack.push dividend / divisor + @stack.push(dividend / divisor) end end diff --git a/examples/i18n/zh-CN/lib/calculator.rb b/examples/i18n/zh-CN/lib/calculator.rb index 086ad16c5..e592772e8 100644 --- a/examples/i18n/zh-CN/lib/calculator.rb +++ b/examples/i18n/zh-CN/lib/calculator.rb @@ -1,12 +1,15 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.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 c8672e7b6..9a111bdee 100644 --- a/examples/i18n/zh-TW/lib/calculator.rb +++ b/examples/i18n/zh-TW/lib/calculator.rb @@ -1,16 +1,19 @@ # frozen_string_literal: true class Calculator - def push(n) - @args ||= [] - @args << n + def initialize + @stack = [] + end + + def push(arg) + @stack.push(arg) end def add - @args.inject(0) { |n, sum| sum + n } + @stack.inject(0) { |n, sum| sum + n } end def divide - @args[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end From ee9cc6a9395ec14df2ac7d01b9d0ef87b5a508fd Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Mon, 2 Oct 2023 15:25:46 +0100 Subject: [PATCH 5/9] Regen of config / todo config --- .rubocop.yml | 18 ------------------ .rubocop_todo.yml | 40 +++++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 35 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b465ce6ac..042cde4e5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -91,24 +91,6 @@ Naming/MethodName: - 'examples/i18n/he/lib/calculator.rb' - 'lib/cucumber/glue/dsl.rb' -## In most cases, being descriptive with parameter names helps a reader understand -## what the variable is for. In some cases, shorter names are sufficient. -#Naming/MethodParameterName: -# AllowedNames: _, e, n, v, id, io, gh, pr - -# Reviewed: these offenses look false as the variables are in cyrillic -Naming/VariableName: - Exclude: - - 'examples/i18n/ru/features/step_definitions/calculator_steps.rb' - - 'examples/i18n/uk/features/step_definitions/calculator_steps.rb' - - 'examples/i18n/uz/features/step_definitions/calculator_steps.rb' - -# Rubocop doesn't handle some international words well for this cop -Naming/VariableNumber: - EnforcedStyle: normalcase - Exclude: - - 'examples/i18n/**/*' - RSpec/ExampleLength: CountAsOne: ['array', 'hash', 'heredoc'] diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ee4648a73..90fe067dd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-10-02 12:57:00 UTC using RuboCop version 1.56.3. +# on 2023-10-02 14:25:13 UTC using RuboCop version 1.56.4. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -88,21 +88,11 @@ Lint/RescueException: Exclude: - 'lib/cucumber/glue/proto_world.rb' -# Offense count: 1 -# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. -Metrics/AbcSize: - Max: 50 - # Offense count: 8 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 12 -# Offense count: 1 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -Metrics/MethodLength: - Max: 57 - # Offense count: 7 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: @@ -116,6 +106,28 @@ Naming/FileName: Exclude: - 'features/lib/step_definitions/iso-8859-1_steps.rb' +# Offense count: 14 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'lib/cucumber/cli/options.rb' + - 'lib/cucumber/formatter/ansicolor.rb' + - 'lib/cucumber/formatter/console.rb' + - 'lib/cucumber/gherkin/formatter/ansi_escapes.rb' + - 'lib/cucumber/multiline_argument/data_table.rb' + +# Offense count: 8 +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. +# SupportedStyles: snake_case, normalcase, non_integer +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 +Naming/VariableNumber: + Exclude: + - 'examples/i18n/bg/lib/calculator.rb' + - 'examples/i18n/ru/lib/calculator.rb' + - 'examples/i18n/uk/lib/calculator.rb' + - 'examples/i18n/uz/lib/calculator.rb' + # Offense count: 2 RSpec/AnyInstance: Exclude: @@ -146,11 +158,6 @@ RSpec/ContextWording: # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: Exclude: - - '**/spec/features/**/*' - - '**/spec/requests/**/*' - - '**/spec/routing/**/*' - - '**/spec/system/**/*' - - '**/spec/views/**/*' - 'spec/cck/cck_spec.rb' # Offense count: 8 @@ -195,7 +202,6 @@ RSpec/ExampleWording: # This cop supports safe autocorrection (--autocorrect). RSpec/ExpectActual: Exclude: - - '**/spec/routing/**/*' - 'spec/cucumber/cli/configuration_spec.rb' - 'spec/cucumber/step_match_spec.rb' From 1c460c8a4e61311eb48557a288b864f924cced26 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Mon, 2 Oct 2023 17:25:02 +0100 Subject: [PATCH 6/9] Update changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3dd2e049..71d8d473c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,8 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo ## [Unreleased] ### Changed -- First couple of passes of tidying up approximately 30% of the manual fix cops - ([#1739](https://github.com/cucumber/cucumber-ruby/pull/1739) [#1740](https://github.com/cucumber/cucumber-ruby/pull/1740) [luke-hill](https://github.com/luke-hill)) +- First couple of passes of tidying up approximately 40% of the manual fix cops + ([#1739](https://github.com/cucumber/cucumber-ruby/pull/1739) [#1740](https://github.com/cucumber/cucumber-ruby/pull/1740) [#1741](https://github.com/cucumber/cucumber-ruby/pull/1741) [luke-hill](https://github.com/luke-hill)) - Removed a bunch of example files / sample projects from ancient projects no longer viable [#1740](https://github.com/cucumber/cucumber-ruby/pull/1740) [luke-hill](https://github.com/luke-hill)) From f2ae37c2e00dbdf8f04ac0fec75f8d8e59a89d0b Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Mon, 2 Oct 2023 17:26:14 +0100 Subject: [PATCH 7/9] Fix issue with cs feature copied incorrectly --- examples/i18n/cs/lib/calculator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/i18n/cs/lib/calculator.rb b/examples/i18n/cs/lib/calculator.rb index b85f6ed29..9a111bdee 100644 --- a/examples/i18n/cs/lib/calculator.rb +++ b/examples/i18n/cs/lib/calculator.rb @@ -14,6 +14,6 @@ def add end def divide - @stack[0].to_f / @args[1] + @stack[0].to_f / @stack[1] end end From 96686d9a8b9aaafcacfade3314e91d4f1851a982 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Mon, 2 Oct 2023 17:28:15 +0100 Subject: [PATCH 8/9] Fix pending spec --- lib/cucumber/runtime/for_programming_languages.rb | 3 +-- spec/cucumber/runtime/for_programming_languages_spec.rb | 9 --------- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 spec/cucumber/runtime/for_programming_languages_spec.rb diff --git a/lib/cucumber/runtime/for_programming_languages.rb b/lib/cucumber/runtime/for_programming_languages.rb index 877644a14..d187d578f 100644 --- a/lib/cucumber/runtime/for_programming_languages.rb +++ b/lib/cucumber/runtime/for_programming_languages.rb @@ -7,8 +7,7 @@ module Cucumber class Runtime # This is what a programming language will consider to be a runtime. # - # It's a thin class that directs the handul of methods needed by the - # programming languages to the right place. + # It's a thin class that directs the handful of methods needed by the programming languages to the right place class ForProgrammingLanguages extend Forwardable diff --git a/spec/cucumber/runtime/for_programming_languages_spec.rb b/spec/cucumber/runtime/for_programming_languages_spec.rb deleted file mode 100644 index 899073384..000000000 --- a/spec/cucumber/runtime/for_programming_languages_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -module Cucumber - describe Runtime::ForProgrammingLanguages do - it 'should probably be inlined' - end -end From 28bd1746ec6b1e5b423809d6ebda4d4e5568003f Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Mon, 2 Oct 2023 17:39:48 +0100 Subject: [PATCH 9/9] Fix bug with finnish translation of push that was missed during refactor --- examples/i18n/fi/lib/laskin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/i18n/fi/lib/laskin.rb b/examples/i18n/fi/lib/laskin.rb index dc7333f2a..f52a643ee 100644 --- a/examples/i18n/fi/lib/laskin.rb +++ b/examples/i18n/fi/lib/laskin.rb @@ -5,7 +5,7 @@ def initialize @stack = [] end - def push(arg) + def pinoa(arg) @stack.push(arg) end