From 78fee52f17ddff3a925f9ebe1b16320a9e4b2c57 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sat, 13 Jul 2024 15:09:32 +0930 Subject: [PATCH] Ruby 3.2: Upgrade Rubocop and add more rubocop helpers (#3779) * Ruby 3.2/Bundler 2.4 * Fix creation * Upgrade to js-routes 2. Put all js routes into a global namespace. * Remove js-routes * Remove * Adjust ownership * Appease codeclimate for the nth time * Fix deprecation warning by explicitly calling to_fs * Fix deprecation warning by explicitly calling to_fs * Fix deprecation warning by explicitly calling to_fs * Swap to will paginate successor for bootstrap * Update app/views/members/show.html.haml * Update app/views/plantings/index.rss.haml * Update .env * Update .devcontainer/.env * Fix spec * Update spec * Fix spec * Pin to 2.4.22 * 3 space indent * Regenerate * Update rubocop * Rubocop * More rubocop * Regenerate * Fix config file --- .rubocop.yml | 4 ++ .rubocop_todo.yml | 116 ++++++++++++++++++++++++++++++++++++++++++++-- Gemfile | 3 ++ Gemfile.lock | 9 ++++ 4 files changed, 129 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b42b06f04..629f585a9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,11 @@ inherit_from: .rubocop_todo.yml require: + - rubocop-factory_bot + - rubocop-capybara - rubocop-rails - rubocop-rspec + - rubocop-rspec_rails + - rubocop-rake AllCops: NewCops: enable Exclude: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1336b72aa..62e1540ec 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,93 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-07-13 04:50:02 UTC using RuboCop version 1.65.0. +# on 2024-07-13 05:22:30 UTC using RuboCop version 1.65.0. # 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 # versions of RuboCop, may require this file to be generated again. +# Offense count: 231 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: link_or_button, strict +Capybara/ClickLinkOrButtonStyle: + Enabled: false + +# Offense count: 84 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: have_no, not_to +Capybara/NegationMatcher: + Enabled: false + +# Offense count: 39 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: DefaultSelector. +Capybara/RSpec/HaveSelector: + Exclude: + - 'spec/features/conversations/index_spec.rb' + - 'spec/features/footer_spec.rb' + - 'spec/features/gardens/adding_gardens_spec.rb' + - 'spec/features/harvests/harvesting_a_crop_spec.rb' + - 'spec/features/members/list_spec.rb' + - 'spec/features/plantings/planting_a_crop_spec.rb' + - 'spec/features/seeds/adding_seeds_spec.rb' + - 'spec/features/shared_examples/crop_suggest.rb' + - 'spec/helpers/application_helper_spec.rb' + - 'spec/support/feature_helpers.rb' + - 'spec/views/posts/show.html.haml_spec.rb' + +# Offense count: 14 +Capybara/SpecificMatcher: + Exclude: + - 'spec/features/footer_spec.rb' + - 'spec/features/gardens/adding_gardens_spec.rb' + - 'spec/features/harvests/harvesting_a_crop_spec.rb' + - 'spec/features/plantings/planting_a_crop_spec.rb' + - 'spec/features/seeds/adding_seeds_spec.rb' + +# Offense count: 1 +Capybara/VisibilityMatcher: + Exclude: + - 'spec/features/shared_examples/crop_suggest.rb' + +# Offense count: 6 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, NonImplicitAssociationMethodNames. +# SupportedStyles: explicit, implicit +FactoryBot/AssociationStyle: + Exclude: + - 'spec/factories/alternate_names.rb' + - 'spec/factories/crop.rb' + - 'spec/factories/like.rb' + - 'spec/factories/scientific_name.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect, Include, EnforcedStyle, ExplicitOnly. +# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb +# SupportedStyles: create_list, n_times +FactoryBot/CreateList: + Exclude: + - 'spec/views/comments/index.rss.haml_spec.rb' + - 'spec/views/photos/index.html.haml_spec.rb' + - 'spec/views/posts/index.html.haml_spec.rb' + +# Offense count: 4 +# Configuration parameters: Include, MaxAmount. +# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb +FactoryBot/ExcessiveCreateList: + Exclude: + - 'spec/controllers/posts_controller_spec.rb' + - 'spec/features/crops/show_spec.rb' + - 'spec/features/percy/percy_spec.rb' + +# Offense count: 1127 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Include. +# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb +FactoryBot/SyntaxMethods: + Enabled: false + # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleAlignWith. @@ -154,6 +236,12 @@ Lint/EmptyBlock: - 'spec/features/crops/crop_detail_page_spec.rb' - 'spec/requests/authentications_spec.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/RedundantCopDisableDirective: + Exclude: + - 'db/migrate/20230313015323_create_active_storage_tables.active_storage.rb' + # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). Lint/RedundantDirGlobSort: @@ -187,7 +275,7 @@ Lint/UselessAssignment: Metrics/AbcSize: Max: 151 -# Offense count: 13 +# Offense count: 14 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: @@ -203,7 +291,7 @@ Metrics/ClassLength: Metrics/CyclomaticComplexity: Max: 32 -# Offense count: 70 +# Offense count: 71 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 127 @@ -439,6 +527,23 @@ RSpec/VerifiedDoubles: - 'spec/controllers/gardens_controller_spec.rb' - 'spec/views/devise/shared/_links_spec.rb' +# Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ResponseMethods. +# ResponseMethods: response, last_response +RSpecRails/HaveHttpStatus: + Exclude: + - 'spec/controllers/api/v1/plantings_controller_spec.rb' + - 'spec/controllers/harvests_controller_spec.rb' + - 'spec/controllers/likes_controller_spec.rb' + - 'spec/requests/harvests_spec.rb' + +# Offense count: 16 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Inferences. +RSpecRails/InferredSpecType: + Enabled: false + # Offense count: 28 # Configuration parameters: Database, Include. # SupportedDatabases: mysql, postgresql @@ -629,6 +734,11 @@ Rails/WhereRange: - 'app/models/concerns/predict_planting.rb' - 'app/models/garden.rb' +# Offense count: 1 +Rake/MethodDefinitionInTask: + Exclude: + - 'lib/tasks/growstuff.rake' + # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. diff --git a/Gemfile b/Gemfile index 3fae781ae..5a19c18ae 100644 --- a/Gemfile +++ b/Gemfile @@ -167,7 +167,10 @@ group :development, :test do gem 'rspec-activemodel-mocks' gem 'rspec-rails' # unit testing framework gem 'rswag-specs' + gem 'rubocop-capybara' + gem 'rubocop-factory_bot' gem 'rubocop-rails' + gem 'rubocop-rake' gem 'rubocop-rspec' gem 'rubocop-rspec_rails' gem 'webrat' # provides HTML matchers for view tests diff --git a/Gemfile.lock b/Gemfile.lock index dc2f7205b..b94ab9127 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -575,11 +575,17 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.31.3) parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.26.1) + rubocop (~> 1.61) rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) rubocop-rspec (3.0.2) rubocop (~> 1.61) rubocop-rspec_rails (2.30.0) @@ -774,7 +780,10 @@ DEPENDENCIES rswag-specs rswag-ui rubocop + rubocop-capybara + rubocop-factory_bot rubocop-rails + rubocop-rake rubocop-rspec rubocop-rspec_rails ruby-units