From c08e264afa8484229822b2858f548dd3fd02775d Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 19 Apr 2023 13:01:55 +1000 Subject: [PATCH 1/9] Add script for bulk autocorrect with Rubocop We also had an old script which wasn't used and needed manual steps. --- script/rubocop-autocorrect.sh | 27 +++++++++++++++++++++++++++ script/rubocop_autocorrect | 19 ------------------- 2 files changed, 27 insertions(+), 19 deletions(-) create mode 100755 script/rubocop-autocorrect.sh delete mode 100755 script/rubocop_autocorrect diff --git a/script/rubocop-autocorrect.sh b/script/rubocop-autocorrect.sh new file mode 100755 index 0000000000..c046d8e05c --- /dev/null +++ b/script/rubocop-autocorrect.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# Fixes safe cops automatically and creates a commit for each. +# + +if git add --dry-run --all | grep --quiet .; then + echo "Dirty working tree. Please start on a fresh branch." + exit 1 +fi + +# Refresh todo file so that following commits include only related changes: +bundle exec rubocop --regenerate-todo +git commit --all --message "Regenerate Rubocop's TODO file" + +# Iterate over all safe cops: +grep "This cop supports safe autocorrection" -A 5 .rubocop_todo.yml\ + | grep '^[A-Z]'\ + | tr -d :\ + | while read cop; do + echo "Trying to autocorrect safely: $cop" + bundle exec rubocop --regenerate-todo --except "$cop" + + echo "Safely autocorrect $cop\n" > .git/COMMIT_EDITMSG + bundle exec rubocop --autocorrect >> .git/COMMIT_EDITMSG + git add --all + git commit --file .git/COMMIT_EDITMSG + done diff --git a/script/rubocop_autocorrect b/script/rubocop_autocorrect deleted file mode 100755 index f9e7cac2fc..0000000000 --- a/script/rubocop_autocorrect +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# Usage -# -# 1. Clean any git unstagged or untracked changes. Consider creating a new branch -# 2. Remove a cop's exclusion paragraph from the .rubocop_todo.yml -# 3. Run: -# -# $ ./script/rubocop_autocorrect -# -# This will commit all the changes. - -set -e - -COP="$1" - -bundle exec rubocop -a --only "$COP" -git add -A -git commit -m "Auto correct Rubocop's ${COP} cop" From 52f134fc9e8c0dd33cdb67775482c2364fc18bfd Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 19 Apr 2023 15:25:20 +1000 Subject: [PATCH 2/9] Regenerate Rubocop's TODO file --- .rubocop_todo.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f7c1a784b2..8189cb6f12 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400` -# on 2023-04-14 06:27:24 UTC using RuboCop version 1.50.1. +# on 2023-04-19 05:25:17 UTC using RuboCop version 1.50.2. # 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 @@ -114,13 +114,6 @@ Layout/EmptyLinesAroundBlockBody: - 'spec/requests/checkout/concurrency_spec.rb' - 'spec/system/admin/order_cycles/list_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'spec/spec_helper.rb' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -236,7 +229,7 @@ Layout/LineEndStringConcatenationIndentation: - 'spec/system/consumer/cookies_spec.rb' - 'spec/system/consumer/shopping/cart_spec.rb' -# Offense count: 605 +# Offense count: 615 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https @@ -449,7 +442,7 @@ Layout/TrailingEmptyLines: Exclude: - 'Rakefile' -# Offense count: 67 +# Offense count: 70 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: From dc560d379348f873636a5ccf7ddc588cd14cd8ea Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 19 Apr 2023 15:27:10 +1000 Subject: [PATCH 3/9] Safely autocorrect Bundler/OrderedGems Inspecting 1404 files .C.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... Offenses: Gemfile:18:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem angular-rails-templates should appear before rexml. gem 'angular-rails-templates', '>= 0.3.0' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:19:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem awesome_nested_set should appear before rexml. gem 'awesome_nested_set' ^^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:20:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem ransack should appear before rexml. gem 'ransack', '~> 2.6.0' ^^^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:21:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem responders should appear before rexml. gem 'responders' ^^^^^^^^^^^^^^^^ Gemfile:74:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem omniauth-rails_csrf_protection should appear before openid_connect. gem 'omniauth-rails_csrf_protection' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:154:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before factory_bot_rails. gem 'debug', '>= 1.0.0' ^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:155:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before fuubar. gem 'debug', '>= 1.0.0' ^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:156:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before json_spec. gem 'debug', '>= 1.0.0' ^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:157:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before knapsack_pro. gem 'debug', '>= 1.0.0' ^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:158:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before letter_opener. gem 'debug', '>= 1.0.0' ^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:159:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before rspec-rails. gem 'debug', '>= 1.0.0' ^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:160:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before rspec-retry. gem 'debug', '>= 1.0.0' ^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:161:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before rswag-specs. gem 'debug', '>= 1.0.0' ^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:162:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before shoulda-matchers. gem 'debug', '>= 1.0.0' ^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:163:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before timecop. gem 'debug', '>= 1.0.0' ^^^^^^^^^^^^^^^^^^^^^^^ Gemfile:179:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem foreman should appear before rails-erd. gem 'foreman' ^^^^^^^^^^^^^ Gemfile:180:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem listen should appear before rails-erd. gem 'listen' ^^^^^^^^^^^^ Gemfile:181:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem pry should appear before rails-erd. gem 'pry', '~> 0.13.0' ^^^^^^^^^^^^^^^^^^^^^^ 1404 files inspected, 18 offenses detected, 18 offenses corrected --- .rubocop_todo.yml | 10 +--------- Gemfile | 8 ++++---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8189cb6f12..03c317ee30 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,19 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400` -# on 2023-04-19 05:25:17 UTC using RuboCop version 1.50.2. +# on 2023-04-19 05:26:36 UTC using RuboCop version 1.50.2. # 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: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. -# Include: **/*.gemfile, **/Gemfile, **/gems.rb -Bundler/OrderedGems: - Exclude: - - 'Gemfile' - # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Severity, Include. diff --git a/Gemfile b/Gemfile index 0804c24aff..4391b6d87d 100644 --- a/Gemfile +++ b/Gemfile @@ -14,11 +14,11 @@ gem "aws-sdk-s3", require: false gem "image_processing" gem 'activemerchant', '>= 1.78.0' -gem 'rexml' gem 'angular-rails-templates', '>= 0.3.0' gem 'awesome_nested_set' gem 'ransack', '~> 2.6.0' gem 'responders' +gem 'rexml' gem 'webpacker', '~> 5' gem 'i18n' @@ -70,8 +70,8 @@ gem 'rswag-api' gem 'rswag-ui' gem 'omniauth_openid_connect' -gem 'openid_connect', '~> 1.3' gem 'omniauth-rails_csrf_protection' +gem 'openid_connect', '~> 1.3' gem 'angularjs-rails', '1.8.0' gem 'bugsnag' @@ -150,6 +150,7 @@ group :test, :development do gem 'capybara' gem 'cuprite' gem 'database_cleaner', require: false + gem 'debug', '>= 1.0.0' gem "factory_bot_rails", '6.2.0', require: false gem 'fuubar', '~> 2.5.1' gem 'json_spec', '~> 1.1.4' @@ -160,7 +161,6 @@ group :test, :development do gem 'rswag-specs' gem 'shoulda-matchers' gem 'timecop' - gem 'debug', '>= 1.0.0' end group :test do @@ -175,10 +175,10 @@ end group :development do gem 'debugger-linecache' - gem 'rails-erd' gem 'foreman' gem 'listen' gem 'pry', '~> 0.13.0' + gem 'rails-erd' gem 'rubocop' gem 'rubocop-rails' gem 'spring' From bde46fa1e9dc20e963620f5b8a8174a6d097e202 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 19 Apr 2023 15:29:00 +1000 Subject: [PATCH 4/9] Safely autocorrect Gemspec/DeprecatedAttributeAssignment Inspecting 1404 files .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................W.....................W....................................W...........................W....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... Offenses: engines/catalog/catalog.gemspec:14:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec. s.test_files = Dir["test/**/*"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ engines/dfc_provider/dfc_provider.gemspec:17:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec. spec.test_files = Dir['spec/**/*'] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ engines/order_management/order_management.gemspec:14:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec. s.test_files = Dir["spec/**/*"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ engines/web/web.gemspec:14:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec. s.test_files = Dir["test/**/*"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1404 files inspected, 4 offenses detected, 4 offenses corrected --- .rubocop_todo.yml | 13 +------------ engines/catalog/catalog.gemspec | 1 - engines/dfc_provider/dfc_provider.gemspec | 1 - engines/order_management/order_management.gemspec | 1 - engines/web/web.gemspec | 1 - 5 files changed, 1 insertion(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 03c317ee30..5ff9310171 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,22 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400` -# on 2023-04-19 05:26:36 UTC using RuboCop version 1.50.2. +# on 2023-04-19 05:28:26 UTC using RuboCop version 1.50.2. # 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: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec -Gemspec/DeprecatedAttributeAssignment: - Exclude: - - 'engines/catalog/catalog.gemspec' - - 'engines/dfc_provider/dfc_provider.gemspec' - - 'engines/order_management/order_management.gemspec' - - 'engines/web/web.gemspec' - # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Severity, Include. diff --git a/engines/catalog/catalog.gemspec b/engines/catalog/catalog.gemspec index a20f6d0e04..846a0ddbfd 100644 --- a/engines/catalog/catalog.gemspec +++ b/engines/catalog/catalog.gemspec @@ -11,5 +11,4 @@ Gem::Specification.new do |s| s.summary = "Catalog domain of the OFN solution." s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE.txt", "Rakefile", "README.rdoc"] - s.test_files = Dir["test/**/*"] end diff --git a/engines/dfc_provider/dfc_provider.gemspec b/engines/dfc_provider/dfc_provider.gemspec index e5f306fc53..10c5551a29 100644 --- a/engines/dfc_provider/dfc_provider.gemspec +++ b/engines/dfc_provider/dfc_provider.gemspec @@ -14,7 +14,6 @@ Gem::Specification.new do |spec| 'specifications' spec.files = Dir["{app,config,lib}/**/*"] + ['README.md'] - spec.test_files = Dir['spec/**/*'] spec.add_dependency 'active_model_serializers', '~> 0.8.4' spec.add_dependency 'jwt', '~> 2.2' diff --git a/engines/order_management/order_management.gemspec b/engines/order_management/order_management.gemspec index a5ff6759bc..20c6bad154 100644 --- a/engines/order_management/order_management.gemspec +++ b/engines/order_management/order_management.gemspec @@ -11,5 +11,4 @@ Gem::Specification.new do |s| s.summary = "Order Management domain of the OFN solution." s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE.txt", "Rakefile", "README.rdoc"] - s.test_files = Dir["spec/**/*"] end diff --git a/engines/web/web.gemspec b/engines/web/web.gemspec index ebc9d4d1e7..2cbef7f50f 100644 --- a/engines/web/web.gemspec +++ b/engines/web/web.gemspec @@ -11,5 +11,4 @@ Gem::Specification.new do |s| s.summary = "Web domain of the OFN solution." s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE.txt", "Rakefile", "README.rdoc"] - s.test_files = Dir["test/**/*"] end From 213fb42a052f9e108239ef8e48799692bba17afd Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 19 Apr 2023 15:30:46 +1000 Subject: [PATCH 5/9] Safely autocorrect Gemspec/RequireMFA Inspecting 1404 files .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................W.....................W....................................W...........................W....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... Offenses: engines/catalog/catalog.gemspec:7:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'. Gem::Specification.new do |s| ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ engines/catalog/catalog.gemspec:14:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected. s.metadata['rubygems_mfa_required'] = 'true' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ engines/dfc_provider/dfc_provider.gemspec:9:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'. Gem::Specification.new do |spec| ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ engines/dfc_provider/dfc_provider.gemspec:21:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected. spec.metadata['rubygems_mfa_required'] = 'true' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ engines/order_management/order_management.gemspec:7:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'. Gem::Specification.new do |s| ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ engines/order_management/order_management.gemspec:14:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected. s.metadata['rubygems_mfa_required'] = 'true' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ engines/web/web.gemspec:7:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'. Gem::Specification.new do |s| ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ engines/web/web.gemspec:14:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected. s.metadata['rubygems_mfa_required'] = 'true' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1404 files inspected, 8 offenses detected, 8 offenses corrected --- .rubocop_todo.yml | 13 +------------ engines/catalog/catalog.gemspec | 1 + engines/dfc_provider/dfc_provider.gemspec | 1 + engines/order_management/order_management.gemspec | 1 + engines/web/web.gemspec | 1 + 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5ff9310171..01ac8ccc8e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,22 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400` -# on 2023-04-19 05:28:26 UTC using RuboCop version 1.50.2. +# on 2023-04-19 05:30:13 UTC using RuboCop version 1.50.2. # 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: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec -Gemspec/RequireMFA: - Exclude: - - 'engines/catalog/catalog.gemspec' - - 'engines/dfc_provider/dfc_provider.gemspec' - - 'engines/order_management/order_management.gemspec' - - 'engines/web/web.gemspec' - # Offense count: 4 # Configuration parameters: Severity, Include. # Include: **/*.gemspec diff --git a/engines/catalog/catalog.gemspec b/engines/catalog/catalog.gemspec index 846a0ddbfd..2354adf5eb 100644 --- a/engines/catalog/catalog.gemspec +++ b/engines/catalog/catalog.gemspec @@ -11,4 +11,5 @@ Gem::Specification.new do |s| s.summary = "Catalog domain of the OFN solution." s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE.txt", "Rakefile", "README.rdoc"] + s.metadata['rubygems_mfa_required'] = 'true' end diff --git a/engines/dfc_provider/dfc_provider.gemspec b/engines/dfc_provider/dfc_provider.gemspec index 10c5551a29..423ec96753 100644 --- a/engines/dfc_provider/dfc_provider.gemspec +++ b/engines/dfc_provider/dfc_provider.gemspec @@ -18,4 +18,5 @@ Gem::Specification.new do |spec| spec.add_dependency 'active_model_serializers', '~> 0.8.4' spec.add_dependency 'jwt', '~> 2.2' spec.add_dependency 'rspec', '~> 3.9' + spec.metadata['rubygems_mfa_required'] = 'true' end diff --git a/engines/order_management/order_management.gemspec b/engines/order_management/order_management.gemspec index 20c6bad154..6adda89bd7 100644 --- a/engines/order_management/order_management.gemspec +++ b/engines/order_management/order_management.gemspec @@ -11,4 +11,5 @@ Gem::Specification.new do |s| s.summary = "Order Management domain of the OFN solution." s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE.txt", "Rakefile", "README.rdoc"] + s.metadata['rubygems_mfa_required'] = 'true' end diff --git a/engines/web/web.gemspec b/engines/web/web.gemspec index 2cbef7f50f..070aa06648 100644 --- a/engines/web/web.gemspec +++ b/engines/web/web.gemspec @@ -11,4 +11,5 @@ Gem::Specification.new do |s| s.summary = "Web domain of the OFN solution." s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE.txt", "Rakefile", "README.rdoc"] + s.metadata['rubygems_mfa_required'] = 'true' end From 0ac2358f2c4124723bfe6ef93adfc7f9d89f07ad Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 20 Apr 2023 10:34:35 +1000 Subject: [PATCH 6/9] Regenerate Rubocop's TODO file without timestamp --- .rubocop_todo.yml | 4 ++-- script/rubocop-autocorrect.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 01ac8ccc8e..dc22595479 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by -# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400` -# on 2023-04-19 05:30:13 UTC using RuboCop version 1.50.2. +# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp` +# using RuboCop version 1.50.2. # 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 diff --git a/script/rubocop-autocorrect.sh b/script/rubocop-autocorrect.sh index c046d8e05c..b4f7c4186e 100755 --- a/script/rubocop-autocorrect.sh +++ b/script/rubocop-autocorrect.sh @@ -9,7 +9,7 @@ if git add --dry-run --all | grep --quiet .; then fi # Refresh todo file so that following commits include only related changes: -bundle exec rubocop --regenerate-todo +bundle exec rubocop --regenerate-todo --no-auto-gen-timestamp git commit --all --message "Regenerate Rubocop's TODO file" # Iterate over all safe cops: From f71e5ee43c22eb8dcd9643c05b39a5e4b623fa9f Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 20 Apr 2023 10:41:36 +1000 Subject: [PATCH 7/9] Limit number of rubocop autocorrect runs The typical use case is to create a small number of commits for a pull request to ease the review. And you can still run it for all cops with `-n 999` or `-n -0`. --- script/rubocop-autocorrect.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/script/rubocop-autocorrect.sh b/script/rubocop-autocorrect.sh index b4f7c4186e..b49e19639b 100755 --- a/script/rubocop-autocorrect.sh +++ b/script/rubocop-autocorrect.sh @@ -1,7 +1,12 @@ -#!/bin/sh +#!/bin/bash # # Fixes safe cops automatically and creates a commit for each. # +# Usage: +# ./script/rubocop-autocorrect.sh [-n 7] +# +# The optional parameter is passed to `head` to limit the number of iterations. +# Use `-n -0` to remove the limit. if git add --dry-run --all | grep --quiet .; then echo "Dirty working tree. Please start on a fresh branch." @@ -15,6 +20,7 @@ git commit --all --message "Regenerate Rubocop's TODO file" # Iterate over all safe cops: grep "This cop supports safe autocorrection" -A 5 .rubocop_todo.yml\ | grep '^[A-Z]'\ + | head "${@:1}"\ | tr -d :\ | while read cop; do echo "Trying to autocorrect safely: $cop" From 1955a6719c5f16f1579aef9452feef485889c189 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 20 Apr 2023 11:06:37 +1000 Subject: [PATCH 8/9] Fix commit message formatting Git needs a blank line between the summary and the longer description. And `echo` doesn't interpret `\n` by default. --- script/rubocop-autocorrect.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/rubocop-autocorrect.sh b/script/rubocop-autocorrect.sh index b49e19639b..f82dc0f56a 100755 --- a/script/rubocop-autocorrect.sh +++ b/script/rubocop-autocorrect.sh @@ -26,7 +26,8 @@ grep "This cop supports safe autocorrection" -A 5 .rubocop_todo.yml\ echo "Trying to autocorrect safely: $cop" bundle exec rubocop --regenerate-todo --except "$cop" - echo "Safely autocorrect $cop\n" > .git/COMMIT_EDITMSG + echo "Safely autocorrect $cop" > .git/COMMIT_EDITMSG + echo "" >> .git/COMMIT_EDITMSG bundle exec rubocop --autocorrect >> .git/COMMIT_EDITMSG git add --all git commit --file .git/COMMIT_EDITMSG From de8f5e13b306ee5b5cc32c9b71fa80cee1575062 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Mon, 24 Apr 2023 09:39:21 +1000 Subject: [PATCH 9/9] Explain gotcha in case it breaks one day --- script/rubocop-autocorrect.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/script/rubocop-autocorrect.sh b/script/rubocop-autocorrect.sh index f82dc0f56a..7058e4f4ad 100755 --- a/script/rubocop-autocorrect.sh +++ b/script/rubocop-autocorrect.sh @@ -17,7 +17,12 @@ fi bundle exec rubocop --regenerate-todo --no-auto-gen-timestamp git commit --all --message "Regenerate Rubocop's TODO file" -# Iterate over all safe cops: +# Iterate over all safe cops. +# Looking at the 5 lines following the autocorrection comment works for our +# current todo file. If cops start to add more comment lines in the future then +# this may break and not find those cops. +# Alternatives include using `sed` for parsing or running rubocop in fail-fast +# mode to find the next failing cop. grep "This cop supports safe autocorrection" -A 5 .rubocop_todo.yml\ | grep '^[A-Z]'\ | head "${@:1}"\