From e0a5d0cd99897c786bfb80451110d56755327682 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 25 Jun 2024 13:56:41 -0400 Subject: [PATCH] Fix `Rails/ThreeStateBooleanColumn` cop --- db/migrate/.rubocop.yml | 4 ++++ db/migrate/20160325130944_add_admin_to_users.rb | 2 +- db/migrate/20161123093447_add_sensitive_to_statuses.rb | 2 +- .../20170123203248_add_reject_media_to_domain_blocks.rb | 2 +- db/migrate/20170127165745_add_devise_two_factor_to_users.rb | 2 +- db/migrate/20170209184350_add_reply_to_statuses.rb | 2 +- db/migrate/20170330163835_create_imports.rb | 2 +- db/migrate/20170905165803_add_local_to_statuses.rb | 2 +- db/migrate/20181203021853_add_discoverable_to_accounts.rb | 2 +- db/migrate/20190509164208_add_by_moderator_to_tombstone.rb | 2 +- db/migrate/20190805123746_add_capabilities_to_tags.rb | 2 ++ db/migrate/20191212163405_add_hide_collections_to_accounts.rb | 2 +- db/migrate/20200309150742_add_forwarded_to_reports.rb | 2 +- db/migrate/20210609202149_create_login_activities.rb | 2 +- db/migrate/20210621221010_add_skip_sign_in_token_to_users.rb | 2 +- db/migrate/20211031031021_create_preview_card_providers.rb | 2 +- db/migrate/20211115032527_add_trendable_to_preview_cards.rb | 2 +- db/migrate/20220202200743_add_trendable_to_accounts.rb | 2 +- db/migrate/20220202200926_add_trendable_to_statuses.rb | 2 +- ...000827_add_ordered_media_attachment_ids_to_status_edits.rb | 2 +- db/migrate/20240312105620_create_severed_relationships.rb | 2 ++ 21 files changed, 26 insertions(+), 18 deletions(-) diff --git a/db/migrate/.rubocop.yml b/db/migrate/.rubocop.yml index 4e23800dd14..fb436d02d5c 100644 --- a/db/migrate/.rubocop.yml +++ b/db/migrate/.rubocop.yml @@ -2,3 +2,7 @@ inherit_from: ../../.rubocop.yml Naming/VariableNumber: CheckSymbols: false + +Rails/ThreeStateBooleanColumn: + Include: + - '*.rb' diff --git a/db/migrate/20160325130944_add_admin_to_users.rb b/db/migrate/20160325130944_add_admin_to_users.rb index 6b701ebcc83..a78d08a156c 100644 --- a/db/migrate/20160325130944_add_admin_to_users.rb +++ b/db/migrate/20160325130944_add_admin_to_users.rb @@ -2,6 +2,6 @@ class AddAdminToUsers < ActiveRecord::Migration[4.2] def change - add_column :users, :admin, :boolean, default: false + add_column :users, :admin, :boolean, default: false # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20161123093447_add_sensitive_to_statuses.rb b/db/migrate/20161123093447_add_sensitive_to_statuses.rb index 7487b2ee33e..93388126e97 100644 --- a/db/migrate/20161123093447_add_sensitive_to_statuses.rb +++ b/db/migrate/20161123093447_add_sensitive_to_statuses.rb @@ -2,6 +2,6 @@ class AddSensitiveToStatuses < ActiveRecord::Migration[5.0] def change - add_column :statuses, :sensitive, :boolean, default: false + add_column :statuses, :sensitive, :boolean, default: false # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20170123203248_add_reject_media_to_domain_blocks.rb b/db/migrate/20170123203248_add_reject_media_to_domain_blocks.rb index 5282602ce95..d05be7673ea 100644 --- a/db/migrate/20170123203248_add_reject_media_to_domain_blocks.rb +++ b/db/migrate/20170123203248_add_reject_media_to_domain_blocks.rb @@ -2,6 +2,6 @@ class AddRejectMediaToDomainBlocks < ActiveRecord::Migration[5.0] def change - add_column :domain_blocks, :reject_media, :boolean + add_column :domain_blocks, :reject_media, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20170127165745_add_devise_two_factor_to_users.rb b/db/migrate/20170127165745_add_devise_two_factor_to_users.rb index 0f60758d3b5..5e29e2f0037 100644 --- a/db/migrate/20170127165745_add_devise_two_factor_to_users.rb +++ b/db/migrate/20170127165745_add_devise_two_factor_to_users.rb @@ -7,7 +7,7 @@ class AddDeviseTwoFactorToUsers < ActiveRecord::Migration[5.0] t.column :encrypted_otp_secret_iv, :string t.column :encrypted_otp_secret_salt, :string t.column :consumed_timestep, :integer - t.column :otp_required_for_login, :boolean + t.column :otp_required_for_login, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn end end end diff --git a/db/migrate/20170209184350_add_reply_to_statuses.rb b/db/migrate/20170209184350_add_reply_to_statuses.rb index ffef97609da..030ceb4db04 100644 --- a/db/migrate/20170209184350_add_reply_to_statuses.rb +++ b/db/migrate/20170209184350_add_reply_to_statuses.rb @@ -2,7 +2,7 @@ class AddReplyToStatuses < ActiveRecord::Migration[5.0] def up - add_column :statuses, :reply, :boolean, nil: false, default: false + add_column :statuses, :reply, :boolean, default: false # rubocop:disable Rails/ThreeStateBooleanColumn Status.unscoped.update_all('reply = (in_reply_to_id IS NOT NULL)') end diff --git a/db/migrate/20170330163835_create_imports.rb b/db/migrate/20170330163835_create_imports.rb index 6bd9e28b5b3..7548a376d45 100644 --- a/db/migrate/20170330163835_create_imports.rb +++ b/db/migrate/20170330163835_create_imports.rb @@ -5,7 +5,7 @@ class CreateImports < ActiveRecord::Migration[5.0] create_table :imports do |t| t.integer :account_id, null: false t.integer :type, null: false - t.boolean :approved + t.boolean :approved # rubocop:disable Rails/ThreeStateBooleanColumn t.timestamps end diff --git a/db/migrate/20170905165803_add_local_to_statuses.rb b/db/migrate/20170905165803_add_local_to_statuses.rb index cb6307c265a..90f01cb3730 100644 --- a/db/migrate/20170905165803_add_local_to_statuses.rb +++ b/db/migrate/20170905165803_add_local_to_statuses.rb @@ -2,6 +2,6 @@ class AddLocalToStatuses < ActiveRecord::Migration[5.1] def change - add_column :statuses, :local, :boolean, null: true, default: nil + add_column :statuses, :local, :boolean, null: true, default: nil # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20181203021853_add_discoverable_to_accounts.rb b/db/migrate/20181203021853_add_discoverable_to_accounts.rb index 16576aa043e..333a2ce2104 100644 --- a/db/migrate/20181203021853_add_discoverable_to_accounts.rb +++ b/db/migrate/20181203021853_add_discoverable_to_accounts.rb @@ -2,6 +2,6 @@ class AddDiscoverableToAccounts < ActiveRecord::Migration[5.2] def change - add_column :accounts, :discoverable, :boolean + add_column :accounts, :discoverable, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20190509164208_add_by_moderator_to_tombstone.rb b/db/migrate/20190509164208_add_by_moderator_to_tombstone.rb index 656cd0af585..8dfa4cca4ae 100644 --- a/db/migrate/20190509164208_add_by_moderator_to_tombstone.rb +++ b/db/migrate/20190509164208_add_by_moderator_to_tombstone.rb @@ -2,6 +2,6 @@ class AddByModeratorToTombstone < ActiveRecord::Migration[5.2] def change - add_column :tombstones, :by_moderator, :boolean + add_column :tombstones, :by_moderator, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20190805123746_add_capabilities_to_tags.rb b/db/migrate/20190805123746_add_capabilities_to_tags.rb index 949938bb1ef..628617cb7ea 100644 --- a/db/migrate/20190805123746_add_capabilities_to_tags.rb +++ b/db/migrate/20190805123746_add_capabilities_to_tags.rb @@ -4,9 +4,11 @@ class AddCapabilitiesToTags < ActiveRecord::Migration[5.2] def change safety_assured do change_table(:tags, bulk: true) do |t| + # rubocop:disable Rails/ThreeStateBooleanColumn t.column :usable, :boolean t.column :trendable, :boolean t.column :listable, :boolean + # rubocop:enable Rails/ThreeStateBooleanColumn t.column :reviewed_at, :datetime t.column :requested_review_at, :datetime end diff --git a/db/migrate/20191212163405_add_hide_collections_to_accounts.rb b/db/migrate/20191212163405_add_hide_collections_to_accounts.rb index d6740f19b82..0cf1e9fee7a 100644 --- a/db/migrate/20191212163405_add_hide_collections_to_accounts.rb +++ b/db/migrate/20191212163405_add_hide_collections_to_accounts.rb @@ -2,6 +2,6 @@ class AddHideCollectionsToAccounts < ActiveRecord::Migration[5.2] def change - add_column :accounts, :hide_collections, :boolean + add_column :accounts, :hide_collections, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20200309150742_add_forwarded_to_reports.rb b/db/migrate/20200309150742_add_forwarded_to_reports.rb index 60db0167e38..ba835ded3aa 100644 --- a/db/migrate/20200309150742_add_forwarded_to_reports.rb +++ b/db/migrate/20200309150742_add_forwarded_to_reports.rb @@ -2,6 +2,6 @@ class AddForwardedToReports < ActiveRecord::Migration[5.2] def change - add_column :reports, :forwarded, :boolean + add_column :reports, :forwarded, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20210609202149_create_login_activities.rb b/db/migrate/20210609202149_create_login_activities.rb index f2da3359972..4add47a725b 100644 --- a/db/migrate/20210609202149_create_login_activities.rb +++ b/db/migrate/20210609202149_create_login_activities.rb @@ -6,7 +6,7 @@ class CreateLoginActivities < ActiveRecord::Migration[6.1] t.belongs_to :user, null: false, foreign_key: { on_delete: :cascade } t.string :authentication_method t.string :provider - t.boolean :success + t.boolean :success # rubocop:disable Rails/ThreeStateBooleanColumn t.string :failure_reason t.inet :ip t.string :user_agent diff --git a/db/migrate/20210621221010_add_skip_sign_in_token_to_users.rb b/db/migrate/20210621221010_add_skip_sign_in_token_to_users.rb index 8c5d9c368ae..eaeba544737 100644 --- a/db/migrate/20210621221010_add_skip_sign_in_token_to_users.rb +++ b/db/migrate/20210621221010_add_skip_sign_in_token_to_users.rb @@ -2,6 +2,6 @@ class AddSkipSignInTokenToUsers < ActiveRecord::Migration[6.1] def change - add_column :users, :skip_sign_in_token, :boolean + add_column :users, :skip_sign_in_token, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20211031031021_create_preview_card_providers.rb b/db/migrate/20211031031021_create_preview_card_providers.rb index 83255614b60..577cfc53b80 100644 --- a/db/migrate/20211031031021_create_preview_card_providers.rb +++ b/db/migrate/20211031031021_create_preview_card_providers.rb @@ -5,7 +5,7 @@ class CreatePreviewCardProviders < ActiveRecord::Migration[6.1] create_table :preview_card_providers do |t| t.string :domain, null: false, default: '', index: { unique: true } t.attachment :icon - t.boolean :trendable + t.boolean :trendable # rubocop:disable Rails/ThreeStateBooleanColumn t.datetime :reviewed_at t.datetime :requested_review_at t.timestamps diff --git a/db/migrate/20211115032527_add_trendable_to_preview_cards.rb b/db/migrate/20211115032527_add_trendable_to_preview_cards.rb index 21fc4ecf466..561a4d91c01 100644 --- a/db/migrate/20211115032527_add_trendable_to_preview_cards.rb +++ b/db/migrate/20211115032527_add_trendable_to_preview_cards.rb @@ -2,6 +2,6 @@ class AddTrendableToPreviewCards < ActiveRecord::Migration[6.1] def change - add_column :preview_cards, :trendable, :boolean + add_column :preview_cards, :trendable, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20220202200743_add_trendable_to_accounts.rb b/db/migrate/20220202200743_add_trendable_to_accounts.rb index 539717b751d..ad97e1fd1e6 100644 --- a/db/migrate/20220202200743_add_trendable_to_accounts.rb +++ b/db/migrate/20220202200743_add_trendable_to_accounts.rb @@ -4,7 +4,7 @@ class AddTrendableToAccounts < ActiveRecord::Migration[6.1] def change safety_assured do change_table(:accounts, bulk: true) do |t| - t.column :trendable, :boolean + t.column :trendable, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn t.column :reviewed_at, :datetime t.column :requested_review_at, :datetime end diff --git a/db/migrate/20220202200926_add_trendable_to_statuses.rb b/db/migrate/20220202200926_add_trendable_to_statuses.rb index 5d101132b81..3eaf2d0bb0c 100644 --- a/db/migrate/20220202200926_add_trendable_to_statuses.rb +++ b/db/migrate/20220202200926_add_trendable_to_statuses.rb @@ -2,6 +2,6 @@ class AddTrendableToStatuses < ActiveRecord::Migration[6.1] def change - add_column :statuses, :trendable, :boolean + add_column :statuses, :trendable, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn end end diff --git a/db/migrate/20220303000827_add_ordered_media_attachment_ids_to_status_edits.rb b/db/migrate/20220303000827_add_ordered_media_attachment_ids_to_status_edits.rb index 55567d62e17..c3dfc786a59 100644 --- a/db/migrate/20220303000827_add_ordered_media_attachment_ids_to_status_edits.rb +++ b/db/migrate/20220303000827_add_ordered_media_attachment_ids_to_status_edits.rb @@ -7,7 +7,7 @@ class AddOrderedMediaAttachmentIdsToStatusEdits < ActiveRecord::Migration[6.1] t.column :ordered_media_attachment_ids, :bigint, array: true t.column :media_descriptions, :text, array: true t.column :poll_options, :string, array: true - t.column :sensitive, :boolean + t.column :sensitive, :boolean # rubocop:disable Rails/ThreeStateBooleanColumn end end end diff --git a/db/migrate/20240312105620_create_severed_relationships.rb b/db/migrate/20240312105620_create_severed_relationships.rb index 1ed911cd55a..3269298e807 100644 --- a/db/migrate/20240312105620_create_severed_relationships.rb +++ b/db/migrate/20240312105620_create_severed_relationships.rb @@ -14,8 +14,10 @@ class CreateSeveredRelationships < ActiveRecord::Migration[7.0] t.integer :direction, null: false # Those attributes are carried over from the `follows` table + # rubocop:disable Rails/ThreeStateBooleanColumn t.boolean :show_reblogs t.boolean :notify + # rubocop:enable Rails/ThreeStateBooleanColumn t.string :languages, array: true t.timestamps