From 83fc97285b97ceaebb1dd878fd76883ad13dcfd0 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 31 Mar 2023 03:33:25 -0400 Subject: [PATCH] Enable Rubocop Metrics/BlockLength with Excludes (#24260) --- .rubocop.yml | 26 +++++- .rubocop_todo.yml | 213 ---------------------------------------------- 2 files changed, 25 insertions(+), 214 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b5598b65a..dadb2075e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -50,10 +50,34 @@ Metrics/AbcSize: - 'lib/**/*cli*.rb' - db/*migrate/**/* +# Reason: Some functions cannot be broken up, but others may be refactor candidates +# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsblocklength Metrics/BlockLength: - CountAsOne: [array, heredoc] + CountAsOne: ['array', 'hash', 'heredoc', 'method_call'] Exclude: - 'lib/mastodon/*_cli.rb' + - 'lib/tasks/*.rake' + - 'app/models/concerns/account_associations.rb' + - 'app/models/concerns/account_interactions.rb' + - 'app/models/concerns/ldap_authenticable.rb' + - 'app/models/concerns/omniauthable.rb' + - 'app/models/concerns/pam_authenticable.rb' + - 'app/models/concerns/remotable.rb' + - 'app/services/suspend_account_service.rb' + - 'app/services/unsuspend_account_service.rb' + - 'app/views/accounts/show.rss.ruby' + - 'app/views/tags/show.rss.ruby' + - 'config/environments/development.rb' + - 'config/environments/production.rb' + - 'config/initializers/devise.rb' + - 'config/initializers/doorkeeper.rb' + - 'config/initializers/omniauth.rb' + - 'config/initializers/simple_form.rb' + - 'config/navigation.rb' + - 'config/routes.rb' + - 'db/post_migrate/20221101190723_backfill_admin_action_logs.rb' + - 'db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb' + - 'lib/paperclip/gif_transcoder.rb' Metrics/BlockNesting: Exclude: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4ad266c8c..a3832ae70 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -117,7 +117,6 @@ Lint/ConstantDefinitionInBlock: - 'spec/lib/activitypub/adapter_spec.rb' - 'spec/lib/connection_pool/shared_connection_pool_spec.rb' - 'spec/lib/connection_pool/shared_timed_stack_spec.rb' - - 'spec/lib/settings/extend_spec.rb' - 'spec/models/concerns/remotable_spec.rb' # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches. @@ -233,11 +232,6 @@ Lint/Void: Metrics/AbcSize: Max: 150 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. -# AllowedMethods: refine -Metrics/BlockLength: - Max: 544 - # Configuration parameters: CountBlocks, Max. Metrics/BlockNesting: Exclude: @@ -731,7 +725,6 @@ RSpec/LeakyConstantDeclaration: - 'spec/lib/activitypub/adapter_spec.rb' - 'spec/lib/connection_pool/shared_connection_pool_spec.rb' - 'spec/lib/connection_pool/shared_timed_stack_spec.rb' - - 'spec/lib/settings/extend_spec.rb' - 'spec/models/concerns/remotable_spec.rb' RSpec/LetSetup: @@ -881,204 +874,6 @@ RSpec/MultipleSubjects: - 'spec/controllers/follower_accounts_controller_spec.rb' - 'spec/controllers/following_accounts_controller_spec.rb' -# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. -# SupportedStyles: always, named_only -RSpec/NamedSubject: - Exclude: - - 'spec/controllers/admin/account_moderation_notes_controller_spec.rb' - - 'spec/controllers/admin/accounts_controller_spec.rb' - - 'spec/controllers/admin/confirmations_controller_spec.rb' - - 'spec/controllers/admin/custom_emojis_controller_spec.rb' - - 'spec/controllers/admin/domain_blocks_controller_spec.rb' - - 'spec/controllers/admin/instances_controller_spec.rb' - - 'spec/controllers/admin/invites_controller_spec.rb' - - 'spec/controllers/admin/report_notes_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/notes_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/pins_controller_spec.rb' - - 'spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb' - - 'spec/controllers/auth/passwords_controller_spec.rb' - - 'spec/controllers/auth/registrations_controller_spec.rb' - - 'spec/controllers/home_controller_spec.rb' - - 'spec/controllers/invites_controller_spec.rb' - - 'spec/controllers/oauth/authorizations_controller_spec.rb' - - 'spec/controllers/oauth/authorized_applications_controller_spec.rb' - - 'spec/controllers/relationships_controller_spec.rb' - - 'spec/controllers/settings/featured_tags_controller_spec.rb' - - 'spec/controllers/settings/migrations_controller_spec.rb' - - 'spec/controllers/settings/sessions_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb' - - 'spec/controllers/well_known/webfinger_controller_spec.rb' - - 'spec/features/log_in_spec.rb' - - 'spec/features/profile_spec.rb' - - 'spec/lib/activitypub/activity/accept_spec.rb' - - 'spec/lib/activitypub/activity/add_spec.rb' - - 'spec/lib/activitypub/activity/announce_spec.rb' - - 'spec/lib/activitypub/activity/block_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - - 'spec/lib/activitypub/activity/delete_spec.rb' - - 'spec/lib/activitypub/activity/flag_spec.rb' - - 'spec/lib/activitypub/activity/follow_spec.rb' - - 'spec/lib/activitypub/activity/like_spec.rb' - - 'spec/lib/activitypub/activity/move_spec.rb' - - 'spec/lib/activitypub/activity/reject_spec.rb' - - 'spec/lib/activitypub/activity/remove_spec.rb' - - 'spec/lib/activitypub/activity/undo_spec.rb' - - 'spec/lib/activitypub/activity/update_spec.rb' - - 'spec/lib/activitypub/adapter_spec.rb' - - 'spec/lib/activitypub/dereferencer_spec.rb' - - 'spec/lib/activitypub/linked_data_signature_spec.rb' - - 'spec/lib/activitypub/tag_manager_spec.rb' - - 'spec/lib/connection_pool/shared_connection_pool_spec.rb' - - 'spec/lib/connection_pool/shared_timed_stack_spec.rb' - - 'spec/lib/delivery_failure_tracker_spec.rb' - - 'spec/lib/emoji_formatter_spec.rb' - - 'spec/lib/entity_cache_spec.rb' - - 'spec/lib/fast_ip_map_spec.rb' - - 'spec/lib/feed_manager_spec.rb' - - 'spec/lib/hashtag_normalizer_spec.rb' - - 'spec/lib/html_aware_formatter_spec.rb' - - 'spec/lib/link_details_extractor_spec.rb' - - 'spec/lib/ostatus/tag_manager_spec.rb' - - 'spec/lib/plain_text_formatter_spec.rb' - - 'spec/lib/request_pool_spec.rb' - - 'spec/lib/request_spec.rb' - - 'spec/lib/sanitize_config_spec.rb' - - 'spec/lib/status_finder_spec.rb' - - 'spec/lib/status_reach_finder_spec.rb' - - 'spec/lib/suspicious_sign_in_detector_spec.rb' - - 'spec/lib/text_formatter_spec.rb' - - 'spec/lib/vacuum/access_tokens_vacuum_spec.rb' - - 'spec/lib/vacuum/backups_vacuum_spec.rb' - - 'spec/lib/vacuum/feeds_vacuum_spec.rb' - - 'spec/lib/vacuum/media_attachments_vacuum_spec.rb' - - 'spec/lib/vacuum/preview_cards_vacuum_spec.rb' - - 'spec/lib/vacuum/statuses_vacuum_spec.rb' - - 'spec/lib/vacuum/system_keys_vacuum_spec.rb' - - 'spec/models/account/field_spec.rb' - - 'spec/models/account_migration_spec.rb' - - 'spec/models/account_spec.rb' - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/models/account_statuses_filter_spec.rb' - - 'spec/models/admin/account_action_spec.rb' - - 'spec/models/canonical_email_block_spec.rb' - - 'spec/models/concerns/account_interactions_spec.rb' - - 'spec/models/custom_emoji_filter_spec.rb' - - 'spec/models/custom_emoji_spec.rb' - - 'spec/models/follow_spec.rb' - - 'spec/models/home_feed_spec.rb' - - 'spec/models/media_attachment_spec.rb' - - 'spec/models/notification_spec.rb' - - 'spec/models/public_feed_spec.rb' - - 'spec/models/relationship_filter_spec.rb' - - 'spec/models/remote_follow_spec.rb' - - 'spec/models/report_spec.rb' - - 'spec/models/session_activation_spec.rb' - - 'spec/models/setting_spec.rb' - - 'spec/models/status_spec.rb' - - 'spec/models/tag_spec.rb' - - 'spec/models/trends/statuses_spec.rb' - - 'spec/models/trends/tags_spec.rb' - - 'spec/models/user_role_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/models/web/push_subscription_spec.rb' - - 'spec/policies/account_moderation_note_policy_spec.rb' - - 'spec/policies/account_policy_spec.rb' - - 'spec/policies/backup_policy_spec.rb' - - 'spec/policies/custom_emoji_policy_spec.rb' - - 'spec/policies/domain_block_policy_spec.rb' - - 'spec/policies/email_domain_block_policy_spec.rb' - - 'spec/policies/instance_policy_spec.rb' - - 'spec/policies/invite_policy_spec.rb' - - 'spec/policies/relay_policy_spec.rb' - - 'spec/policies/report_note_policy_spec.rb' - - 'spec/policies/report_policy_spec.rb' - - 'spec/policies/settings_policy_spec.rb' - - 'spec/policies/status_policy_spec.rb' - - 'spec/policies/tag_policy_spec.rb' - - 'spec/policies/user_policy_spec.rb' - - 'spec/presenters/familiar_followers_presenter_spec.rb' - - 'spec/serializers/activitypub/note_serializer_spec.rb' - - 'spec/serializers/activitypub/update_poll_serializer_spec.rb' - - 'spec/serializers/rest/account_serializer_spec.rb' - - 'spec/services/account_search_service_spec.rb' - - 'spec/services/account_statuses_cleanup_service_spec.rb' - - 'spec/services/activitypub/fetch_remote_account_service_spec.rb' - - 'spec/services/activitypub/fetch_remote_actor_service_spec.rb' - - 'spec/services/activitypub/fetch_remote_status_service_spec.rb' - - 'spec/services/activitypub/fetch_replies_service_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/after_block_domain_from_account_service_spec.rb' - - 'spec/services/after_block_service_spec.rb' - - 'spec/services/app_sign_up_service_spec.rb' - - 'spec/services/authorize_follow_service_spec.rb' - - 'spec/services/batched_remove_status_service_spec.rb' - - 'spec/services/block_domain_service_spec.rb' - - 'spec/services/block_service_spec.rb' - - 'spec/services/bootstrap_timeline_service_spec.rb' - - 'spec/services/clear_domain_media_service_spec.rb' - - 'spec/services/delete_account_service_spec.rb' - - 'spec/services/fan_out_on_write_service_spec.rb' - - 'spec/services/favourite_service_spec.rb' - - 'spec/services/fetch_link_card_service_spec.rb' - - 'spec/services/fetch_oembed_service_spec.rb' - - 'spec/services/fetch_remote_status_service_spec.rb' - - 'spec/services/fetch_resource_service_spec.rb' - - 'spec/services/follow_service_spec.rb' - - 'spec/services/import_service_spec.rb' - - 'spec/services/mute_service_spec.rb' - - 'spec/services/notify_service_spec.rb' - - 'spec/services/post_status_service_spec.rb' - - 'spec/services/precompute_feed_service_spec.rb' - - 'spec/services/process_mentions_service_spec.rb' - - 'spec/services/purge_domain_service_spec.rb' - - 'spec/services/reblog_service_spec.rb' - - 'spec/services/reject_follow_service_spec.rb' - - 'spec/services/remove_from_followers_service_spec.rb' - - 'spec/services/remove_status_service_spec.rb' - - 'spec/services/report_service_spec.rb' - - 'spec/services/resolve_account_service_spec.rb' - - 'spec/services/resolve_url_service_spec.rb' - - 'spec/services/search_service_spec.rb' - - 'spec/services/suspend_account_service_spec.rb' - - 'spec/services/unallow_domain_service_spec.rb' - - 'spec/services/unblock_domain_service_spec.rb' - - 'spec/services/unblock_service_spec.rb' - - 'spec/services/unfollow_service_spec.rb' - - 'spec/services/unsuspend_account_service_spec.rb' - - 'spec/services/update_account_service_spec.rb' - - 'spec/services/update_status_service_spec.rb' - - 'spec/services/verify_link_service_spec.rb' - - 'spec/validators/blacklisted_email_validator_spec.rb' - - 'spec/validators/email_mx_validator_spec.rb' - - 'spec/validators/note_length_validator_spec.rb' - - 'spec/validators/reaction_validator_spec.rb' - - 'spec/validators/status_length_validator_spec.rb' - - 'spec/validators/status_pin_validator_spec.rb' - - 'spec/validators/unique_username_validator_spec.rb' - - 'spec/workers/activitypub/delivery_worker_spec.rb' - - 'spec/workers/activitypub/distribute_poll_update_worker_spec.rb' - - 'spec/workers/activitypub/distribution_worker_spec.rb' - - 'spec/workers/activitypub/fetch_replies_worker_spec.rb' - - 'spec/workers/activitypub/move_distribution_worker_spec.rb' - - 'spec/workers/activitypub/processing_worker_spec.rb' - - 'spec/workers/activitypub/status_update_distribution_worker_spec.rb' - - 'spec/workers/activitypub/update_distribution_worker_spec.rb' - - 'spec/workers/admin/domain_purge_worker_spec.rb' - - 'spec/workers/domain_block_worker_spec.rb' - - 'spec/workers/domain_clear_media_worker_spec.rb' - - 'spec/workers/feed_insert_worker_spec.rb' - - 'spec/workers/move_worker_spec.rb' - - 'spec/workers/publish_scheduled_announcement_worker_spec.rb' - - 'spec/workers/publish_scheduled_status_worker_spec.rb' - - 'spec/workers/refollow_worker_spec.rb' - - 'spec/workers/regeneration_worker_spec.rb' - - 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb' - - 'spec/workers/scheduler/user_cleanup_scheduler_spec.rb' - - 'spec/workers/unfollow_follow_worker_spec.rb' - - 'spec/workers/web/push_notification_worker_spec.rb' - # Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 6 @@ -1477,7 +1272,6 @@ Rails/CompactBlank: - 'app/helpers/statuses_helper.rb' - 'app/models/concerns/attachmentable.rb' - 'app/models/poll.rb' - - 'app/models/user.rb' - 'app/services/import_service.rb' - 'config/initializers/paperclip.rb' @@ -1528,7 +1322,6 @@ Rails/FilePath: - 'app/validators/reaction_validator.rb' - 'config/environments/test.rb' - 'db/migrate/20170716191202_add_hide_notifications_to_mute.rb' - - 'db/migrate/20170918125918_ids_to_bigints.rb' - 'db/migrate/20171005171936_add_disabled_to_custom_emojis.rb' - 'db/migrate/20171028221157_add_reblogs_to_follows.rb' - 'db/migrate/20171107143332_add_memorial_to_accounts.rb' @@ -1648,7 +1441,6 @@ Rails/IgnoredColumnsAssignment: - 'app/models/email_domain_block.rb' - 'app/models/report.rb' - 'app/models/status_edit.rb' - - 'app/models/user.rb' # Configuration parameters: IgnoreScopes, Include. # Include: app/models/**/*.rb @@ -2530,11 +2322,6 @@ Style/PreferredHashMethods: Exclude: - 'config/initializers/paperclip.rb' -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantBegin: - Exclude: - - 'config/initializers/simple_form.rb' - # This cop supports safe autocorrection (--autocorrect). Style/RedundantConstantBase: Exclude: