diff --git a/.github/workflows/lint-ruby.yml b/.github/workflows/lint-ruby.yml index 277e456146..87f8aee24e 100644 --- a/.github/workflows/lint-ruby.yml +++ b/.github/workflows/lint-ruby.yml @@ -9,6 +9,7 @@ on: - 'Gemfile*' - '.rubocop*.yml' - '.ruby-version' + - 'bin/rubocop' - 'config/brakeman.ignore' - '**/*.rb' - '**/*.rake' @@ -19,6 +20,7 @@ on: - 'Gemfile*' - '.rubocop*.yml' - '.ruby-version' + - 'bin/rubocop' - 'config/brakeman.ignore' - '**/*.rb' - '**/*.rake' diff --git a/bin/rubocop b/bin/rubocop index 369a05bedb..b3801537d4 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -24,4 +24,7 @@ end require "rubygems" require "bundler/setup" +# explicit rubocop config increases performance slightly while avoiding config confusion. +ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) + load Gem.bin_path("rubocop", "rubocop") diff --git a/db/migrate/.rubocop.yml b/db/migrate/.rubocop.yml deleted file mode 100644 index f594b8799a..0000000000 --- a/db/migrate/.rubocop.yml +++ /dev/null @@ -1,16 +0,0 @@ -inherit_from: ../../.rubocop.yml - -# Below are all enabled as workaround for https://docs.rubocop.org/rubocop/configuration.html#path-relativity -# TODO: Delete this file and move above config to base naming config - -Rails/CreateTableWithTimestamps: - Include: - - '*.rb' - -Rails/ThreeStateBooleanColumn: - Include: - - '*.rb' - -Rails/ReversibleMigration: - Include: - - '*.rb' diff --git a/db/migrate/20170112154826_migrate_settings.rb b/db/migrate/20170112154826_migrate_settings.rb index d1faa81f5d..166d90eab7 100644 --- a/db/migrate/20170112154826_migrate_settings.rb +++ b/db/migrate/20170112154826_migrate_settings.rb @@ -17,7 +17,7 @@ class MigrateSettings < ActiveRecord::Migration[4.2] t.remove_index [:thing_type, :thing_id, :var] t.rename :thing_id, :target_id t.rename :thing_type, :target_type - t.column :target_id, :integer, null: false + t.column :target_id, :integer, null: false # rubocop:disable Rails/NotNullColumn t.column :target_type, :string, null: false, default: '' t.index [:target_type, :target_id, :var], unique: true end diff --git a/spec/controllers/.rubocop.yml b/spec/controllers/.rubocop.yml deleted file mode 100644 index 51d7c23de1..0000000000 --- a/spec/controllers/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../../.rubocop.yml - -# Anonymous controllers in specs cannot access `described_class`, explanation: -# https://github.com/rubocop/rubocop-rspec/blob/v2.26.1/lib/rubocop/cop/rspec/described_class.rb#L36-L56 -RSpec/DescribedClass: - SkipBlocks: true diff --git a/spec/controllers/concerns/account_controller_concern_spec.rb b/spec/controllers/concerns/account_controller_concern_spec.rb index 384406a0ea..4a44fd3498 100644 --- a/spec/controllers/concerns/account_controller_concern_spec.rb +++ b/spec/controllers/concerns/account_controller_concern_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe AccountControllerConcern do controller(ApplicationController) do - include AccountControllerConcern + include AccountControllerConcern # rubocop:disable RSpec/DescribedClass def success render plain: @account.username # rubocop:disable RSpec/InstanceVariable diff --git a/spec/controllers/concerns/api/rate_limit_headers_spec.rb b/spec/controllers/concerns/api/rate_limit_headers_spec.rb index 6372c94e6c..74ed81f5da 100644 --- a/spec/controllers/concerns/api/rate_limit_headers_spec.rb +++ b/spec/controllers/concerns/api/rate_limit_headers_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe Api::RateLimitHeaders do controller(ApplicationController) do - include Api::RateLimitHeaders + include Api::RateLimitHeaders # rubocop:disable RSpec/DescribedClass def show head 200 diff --git a/spec/controllers/concerns/challengable_concern_spec.rb b/spec/controllers/concerns/challengable_concern_spec.rb index 169e2122f8..01f979ff4c 100644 --- a/spec/controllers/concerns/challengable_concern_spec.rb +++ b/spec/controllers/concerns/challengable_concern_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe ChallengableConcern do controller(ApplicationController) do - include ChallengableConcern + include ChallengableConcern # rubocop:disable RSpec/DescribedClass before_action :require_challenge! diff --git a/spec/controllers/concerns/localized_spec.rb b/spec/controllers/concerns/localized_spec.rb index b1f805ae50..4798e8270c 100644 --- a/spec/controllers/concerns/localized_spec.rb +++ b/spec/controllers/concerns/localized_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe Localized do controller(ApplicationController) do - include Localized + include Localized # rubocop:disable RSpec/DescribedClass def success render plain: I18n.locale, status: 200 diff --git a/spec/controllers/concerns/preloading_concern_spec.rb b/spec/controllers/concerns/preloading_concern_spec.rb index 795afbc45e..2cbccb411e 100644 --- a/spec/controllers/concerns/preloading_concern_spec.rb +++ b/spec/controllers/concerns/preloading_concern_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe PreloadingConcern do controller(ApplicationController) do - include PreloadingConcern + include PreloadingConcern # rubocop:disable RSpec/DescribedClass def empty_array render plain: preload_collection([], Status).size diff --git a/spec/controllers/concerns/settings/export_controller_concern_spec.rb b/spec/controllers/concerns/settings/export_controller_concern_spec.rb index 2c67991e3a..6c1a06114c 100644 --- a/spec/controllers/concerns/settings/export_controller_concern_spec.rb +++ b/spec/controllers/concerns/settings/export_controller_concern_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe Settings::ExportControllerConcern do controller(ApplicationController) do - include Settings::ExportControllerConcern + include Settings::ExportControllerConcern # rubocop:disable RSpec/DescribedClass def index send_export_file diff --git a/spec/controllers/concerns/user_tracking_concern_spec.rb b/spec/controllers/concerns/user_tracking_concern_spec.rb index cc61e285cc..d67b0ef5e7 100644 --- a/spec/controllers/concerns/user_tracking_concern_spec.rb +++ b/spec/controllers/concerns/user_tracking_concern_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe UserTrackingConcern do controller(ApplicationController) do - include UserTrackingConcern + include UserTrackingConcern # rubocop:disable RSpec/DescribedClass def show render plain: 'show'