From d73a14c69b64118c84be31f4efa8e779a674776a Mon Sep 17 00:00:00 2001 From: Luke Hill <20105237+luke-hill@users.noreply.github.com> Date: Tue, 31 Oct 2023 12:38:28 +0000 Subject: [PATCH] v3: rubocop update (#581) * Update rubocop from 1.31 to 1.45 (Large update) * AF: Style/RedundantConstantBase * AF: Style/RedundantStringEscape * Update packaging to latest version to mitigating spam deprecations * Add in latest version of rubocop-rake and reasonably up to date version of rubocop-rails * AF: Rake/Desc * Ignore Environment Rake cop * gsub_file does write to stdout or a form of it now * Update config * Partial update towards later versions of rubocop gems * Fix heredoc warnings * Fix quotes * Add changelog --- .rubocop.yml | 6 ++++ CHANGELOG.md | 1 + Rakefile | 5 ++-- cucumber-rails.gemspec | 10 ++++--- dev_tasks/yard.rake | 28 ------------------ .../yard/default/layout/html/bubble_32x32.png | Bin 1589 -> 0 bytes dev_tasks/yard/default/layout/html/footer.erb | 5 ---- dev_tasks/yard/default/layout/html/index.erb | 1 - dev_tasks/yard/default/layout/html/layout.erb | 25 ---------------- dev_tasks/yard/default/layout/html/logo.erb | 1 - dev_tasks/yard/default/layout/html/setup.rb | 9 ------ lib/cucumber/rails.rb | 19 +++++++----- .../rails/capybara/javascript_emulation.rb | 4 +-- .../rails/capybara/select_dates_and_times.rb | 2 +- lib/cucumber/rails/hooks/mail.rb | 2 +- lib/generators/cucumber/install_generator.rb | 3 -- .../cucumber/install_generator_spec.rb | 2 +- 17 files changed, 33 insertions(+), 90 deletions(-) delete mode 100644 dev_tasks/yard.rake delete mode 100644 dev_tasks/yard/default/layout/html/bubble_32x32.png delete mode 100644 dev_tasks/yard/default/layout/html/footer.erb delete mode 100644 dev_tasks/yard/default/layout/html/index.erb delete mode 100644 dev_tasks/yard/default/layout/html/layout.erb delete mode 100644 dev_tasks/yard/default/layout/html/logo.erb delete mode 100644 dev_tasks/yard/default/layout/html/setup.rb diff --git a/.rubocop.yml b/.rubocop.yml index 04f53ff4..30ac32ca 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,8 @@ require: - rubocop-packaging - rubocop-performance + - rubocop-rails + - rubocop-rake - rubocop-rspec AllCops: @@ -24,6 +26,10 @@ Layout/LineLength: - '^When' - '^Then' +# This cop isn't relevant for our codebase +Rails/RakeEnvironment: + Enabled: false + # This allows us to read the chmod action in a more reproducible way Style/NumericLiteralPrefix: EnforcedOctalStyle: zero_only diff --git a/CHANGELOG.md b/CHANGELOG.md index 81cf47e0..66936f7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This file is intended to be modified using the [`changelog`](github.com/cucumber ## [Unreleased] ### Changed - Add support for Rails 7.1 [#575](https://github.com/cucumber/cucumber-rails/pull/575) +- Added new rubocop sub-gems (rails / rake) and updated versions to 2.6 ruby-conformance [#581](https://github.com/cucumber/cucumber-rails/pull/581) ### Fixed - Some of the rails 5.2 tests were installing lots of old conflicting gems ([luke-hill]) diff --git a/Rakefile b/Rakefile index b6c5d2c4..9d9f6a76 100644 --- a/Rakefile +++ b/Rakefile @@ -34,15 +34,16 @@ namespace :test do end namespace :gemfiles do - desc 'Install dependencies for all gemfiles' + desc 'Re-install dependencies for all gemfiles' task :install do system 'bundle exec appraisal update' end + desc 'Remove all generated gemfiles' task :clean do FileUtils.rm_rf('gemfiles/*') end - desc 'Rebuild generated gemfiles and install dependencies' + desc 'Remove all generated gemfiles and re-install dependencies' task rebuild: %i[clean install] end diff --git a/cucumber-rails.gemspec b/cucumber-rails.gemspec index eb4b6805..a10bd7c7 100644 --- a/cucumber-rails.gemspec +++ b/cucumber-rails.gemspec @@ -36,10 +36,12 @@ Gem::Specification.new do |s| s.add_development_dependency('rails', '>= 5.2', '< 8') s.add_development_dependency('rake', '>= 12.0') s.add_development_dependency('rspec', '~> 3.6') - s.add_development_dependency('rubocop', '~> 1.31.0') - s.add_development_dependency('rubocop-packaging', '~> 0.5.1') - s.add_development_dependency('rubocop-performance', '~> 1.17.0') - s.add_development_dependency('rubocop-rspec', '~> 2.12.0') + s.add_development_dependency('rubocop', '~> 1.45.0') + s.add_development_dependency('rubocop-packaging', '~> 0.5.2') + s.add_development_dependency('rubocop-performance', '~> 1.17.1') + s.add_development_dependency('rubocop-rails', '~> 2.18.0') + s.add_development_dependency('rubocop-rake', '~> 0.6.0') + s.add_development_dependency('rubocop-rspec', '~> 2.17.0') # For Documentation: s.add_development_dependency('yard', '~> 0.9.10') diff --git a/dev_tasks/yard.rake b/dev_tasks/yard.rake deleted file mode 100644 index 5aa03b5e..00000000 --- a/dev_tasks/yard.rake +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -require 'yard' -require 'yard/rake/yardoc_task' - -SITE_DIR = File.expand_path("#{File.dirname(__FILE__)}/../cucumber.github.com") -API_DIR = File.join(SITE_DIR, 'api', 'cucumber-rails', 'ruby', 'yardoc') - -namespace :api do - file :dir do - raise "You need to git clone git@github.com:cucumber/cucumber.github.com.git #{SITE_DIR}" unless File.directory?(SITE_DIR) - - sh('git pull origin master') - mkdir_p API_DIR - end - - template_path = File.expand_path(File.join(File.dirname(__FILE__), 'yard')) - YARD::Templates::Engine.register_template_path(template_path) - YARD::Rake::YardocTask.new(:yard) do |yard| - dir = API_DIR - mkdir_p dir - yard.options = ['--out', dir] - end - task yard: :dir - - desc "Generate YARD docs for Cucumber-Rails' API" - task doc: :yard -end diff --git a/dev_tasks/yard/default/layout/html/bubble_32x32.png b/dev_tasks/yard/default/layout/html/bubble_32x32.png deleted file mode 100644 index 580b07818d01349103145eb3718e570ecc6b13cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1589 zcmV-52Fm$~P)00004b3#c}2nYxW zdf+Z3QSg>X@ELczyHS~kemQP z8INb?dB$(vyZ5pfH+5rsBBl9no^tUq7?d1!X#PEqH;;wQEhrW`^_3dbiqa(){%8U?`u}1=KnkF}@)101uo#K4Vo;_3d z!bp!Q;I)BW&QRZuK)f>c6Jjck-z?JzqelXkQn6>tW4toIS98+~!V%OI&r+2p8_HC1Y7KiD63q1tQbf(5@CNl8Ney}7AvEi4h24k8ht zjoBx)u?b5=paWJ5d{ZUdUI4n1BP85jq;OF(2|#>x4?qZKovpRB7({4e6S6%D9GSpb zEws7CzhbQhT4|5W3edXk|0-tz*xB=S4h+7^P~Qt}{i@A21cF@lIO)Vrno*VO#gmll zR|xeox&C7`bq%m+6EItPi%P>|d-q{_JNE;SN$hS5-ZWwrU; z=PHe9q;M(u7g+Eoah(n#y-cW=9}Wyq@~0^IQ*9jp7#ku)2PxHu#Sm9p5J08jVeH2J zpemsGncCEM+lbTgT>w~X zm?@rOIhZG=y4cQ^`Q-8SOc(p!}L zi+BsKQ(KwEk#Y89ze6gv6+x>>I5J6Gb+dQd30$WGi{Wnd91FGcgxcRcVj(aBDV+_v zjUU{?4?eBnbYh5@>S`G}t&Y`igvg2Z2NgjC7Ubi6{YBtZv^k z8_m1e)lSuDwtf^d#Z#2)mnqjTedaT}UoGDj5hZYy<2haX`uAtj?tx}%K@O*f5dc!O zp7%+c75tT(l8cL`D*QV$Qu)xd7S^Vx6UD2FK2H1PT7-FIpF3C?|3i`FOi zv#Ku}r&h5j>6~vy`ukqKFa@i_-dg1*MmvFVDa6|^9#6-|w;iBQW)Tvu)vs~Qzk+vB zMgP6nD2Lj-3bdadpax8N`9f{&;<^Un}IpVbJ00000NkvXXu0mjfC>s2~ diff --git a/dev_tasks/yard/default/layout/html/footer.erb b/dev_tasks/yard/default/layout/html/footer.erb deleted file mode 100644 index e57a0f2a..00000000 --- a/dev_tasks/yard/default/layout/html/footer.erb +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/dev_tasks/yard/default/layout/html/index.erb b/dev_tasks/yard/default/layout/html/index.erb deleted file mode 100644 index f2356c3d..00000000 --- a/dev_tasks/yard/default/layout/html/index.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yieldall %> diff --git a/dev_tasks/yard/default/layout/html/layout.erb b/dev_tasks/yard/default/layout/html/layout.erb deleted file mode 100644 index 91a72c80..00000000 --- a/dev_tasks/yard/default/layout/html/layout.erb +++ /dev/null @@ -1,25 +0,0 @@ - - - - <%= erb(:headers) %> - - - - - - - - -
<%= yieldall %>
- - <%= erb(:footer) %> - - diff --git a/dev_tasks/yard/default/layout/html/logo.erb b/dev_tasks/yard/default/layout/html/logo.erb deleted file mode 100644 index e834f101..00000000 --- a/dev_tasks/yard/default/layout/html/logo.erb +++ /dev/null @@ -1 +0,0 @@ -

Cucumber-Rails <%= CUCUMBER_RAILS_VERSION %>

diff --git a/dev_tasks/yard/default/layout/html/setup.rb b/dev_tasks/yard/default/layout/html/setup.rb deleted file mode 100644 index 415999a6..00000000 --- a/dev_tasks/yard/default/layout/html/setup.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -def init - super - options[:serializer].serialize( - '/images/bubble_32x32.png', - File.read("#{File.dirname(__FILE__)}/bubble_32x32.png") - ) -end diff --git a/lib/cucumber/rails.rb b/lib/cucumber/rails.rb index 7722dcc3..858693bb 100644 --- a/lib/cucumber/rails.rb +++ b/lib/cucumber/rails.rb @@ -14,9 +14,12 @@ require 'rails/test_help' unless Rails.application.config.cache_classes || defined?(Spring) - warn "WARNING: You have set Rails' config.cache_classes to false - (Spring needs cache_classes set to false). This is known to cause problems - with database transactions. Set config.cache_classes to true if you want to use transactions." + warn <<~MESSAGE + WARNING: You have set Rails' config.cache_classes to false (Spring needs cache_classes set to false). + This is known to cause problems with database transactions. + + Set config.cache_classes to true if you want to use transactions. + MESSAGE end require 'cucumber/rails/world' @@ -31,8 +34,10 @@ MultiTest.disable_autorun else - warn "WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being deferred - until env.rb is called. To avoid this warning, move 'gem \'cucumber-rails\', require: false' - under only group :test in your Gemfile. If already in the :test group, be sure you are - specifying 'require: false'." + warn <<~MESSAGE + WARNING: Cucumber-rails has been required outside of env.rb. The rest of loading is being deferred until env.rb is called. + + To avoid this warning, move `gem 'cucumber-rails', require: false` under `group :test` in your Gemfile. + If it is already in the `:test` group, be sure you are specifying 'require: false'. + MESSAGE end diff --git a/lib/cucumber/rails/capybara/javascript_emulation.rb b/lib/cucumber/rails/capybara/javascript_emulation.rb index 6c3bc2f4..11513d97 100644 --- a/lib/cucumber/rails/capybara/javascript_emulation.rb +++ b/lib/cucumber/rails/capybara/javascript_emulation.rb @@ -108,14 +108,14 @@ class Node Before('not @no-js-emulation') do # Enable javascript emulation - ::Capybara::RackTest::Node.class_eval do + Capybara::RackTest::Node.class_eval do alias_method :click, :click_with_javascript_emulation end end Before('@no-js-emulation') do # Disable javascript emulation - ::Capybara::RackTest::Node.class_eval do + Capybara::RackTest::Node.class_eval do alias_method :click, :click_without_javascript_emulation end end diff --git a/lib/cucumber/rails/capybara/select_dates_and_times.rb b/lib/cucumber/rails/capybara/select_dates_and_times.rb index 1018e9cc..72565d12 100644 --- a/lib/cucumber/rails/capybara/select_dates_and_times.rb +++ b/lib/cucumber/rails/capybara/select_dates_and_times.rb @@ -70,4 +70,4 @@ def get_base_dom_id_from_label_tag(field) end end -World(::Cucumber::Rails::Capybara::SelectDatesAndTimes) +World(Cucumber::Rails::Capybara::SelectDatesAndTimes) diff --git a/lib/cucumber/rails/hooks/mail.rb b/lib/cucumber/rails/hooks/mail.rb index 85761ce9..9002427a 100644 --- a/lib/cucumber/rails/hooks/mail.rb +++ b/lib/cucumber/rails/hooks/mail.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -if defined?(::ActionMailer) +if defined?(ActionMailer) Before do ActionMailer::Base.deliveries = [] end diff --git a/lib/generators/cucumber/install_generator.rb b/lib/generators/cucumber/install_generator.rb index e8b62d23..34e77a95 100644 --- a/lib/generators/cucumber/install_generator.rb +++ b/lib/generators/cucumber/install_generator.rb @@ -53,9 +53,6 @@ def create_database gsub_file 'config/database.yml', /^test:.*\n/, "test: &test\n" gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *test\n" - - # Since gsub_file doesn't ask the user, just inform user that the file was overwritten. - puts ' force config/database.yml' end protected diff --git a/spec/generators/cucumber/install_generator_spec.rb b/spec/generators/cucumber/install_generator_spec.rb index 3e005eeb..61c4f1c2 100644 --- a/spec/generators/cucumber/install_generator_spec.rb +++ b/spec/generators/cucumber/install_generator_spec.rb @@ -65,7 +65,7 @@ def create_config_files_the_generator_is_expected_to_modify it { is_expected.to contain 'load Cucumber::BINARY' } end - if ::Rails::VERSION::MAJOR >= 6 + if Rails::VERSION::MAJOR >= 6 %w[development test].each do |environment| describe "config/environments/#{environment}.rb" do subject { file("config/environments/#{environment}.rb") }