Skip to content

Commit

Permalink
Move the mastodon/*_cli files to mastodon/cli/* (mastodon#24139)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored May 23, 2023
1 parent c9f980b commit b6b4ea4
Show file tree
Hide file tree
Showing 23 changed files with 150 additions and 152 deletions.
18 changes: 8 additions & 10 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Layout/LineLength:
- !ruby/regexp / \# .*$/
- !ruby/regexp /^\# .*$/
Exclude:
- lib/**/*cli*.rb
- 'lib/mastodon/cli/*.rb'
- db/*migrate/**/*
- db/seeds/**/*

Expand All @@ -57,7 +57,7 @@ Lint/UselessAccessModifier:
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsabcsize
Metrics/AbcSize:
Exclude:
- 'lib/**/*cli*.rb'
- 'lib/mastodon/cli/*.rb'
- db/*migrate/**/*

# Reason: Some functions cannot be broken up, but others may be refactor candidates
Expand All @@ -66,7 +66,7 @@ Metrics/BlockLength:
CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
Exclude:
- 'config/routes.rb'
- 'lib/mastodon/*_cli.rb'
- 'lib/mastodon/cli/*.rb'
- 'lib/tasks/*.rake'
- 'app/models/concerns/account_associations.rb'
- 'app/models/concerns/account_interactions.rb'
Expand Down Expand Up @@ -95,14 +95,14 @@ Metrics/BlockLength:
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsblocknesting
Metrics/BlockNesting:
Exclude:
- 'lib/mastodon/*_cli.rb'
- 'lib/mastodon/cli/*.rb'

# Reason: Some Excluded files would be candidates for refactoring but not currently addressed
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsclasslength
Metrics/ClassLength:
CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
Exclude:
- 'lib/mastodon/*_cli.rb'
- 'lib/mastodon/cli/*.rb'
- 'app/controllers/admin/accounts_controller.rb'
- 'app/controllers/api/base_controller.rb'
- 'app/controllers/api/v1/admin/accounts_controller.rb'
Expand Down Expand Up @@ -146,15 +146,15 @@ Metrics/ClassLength:
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricscyclomaticcomplexity
Metrics/CyclomaticComplexity:
Exclude:
- lib/mastodon/*cli*.rb
- lib/mastodon/cli/*.rb
- db/*migrate/**/*

# Reason: Currently disabled in .rubocop_todo.yml
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsmethodlength
Metrics/MethodLength:
CountAsOne: [array, heredoc]
Exclude:
- 'lib/mastodon/*_cli.rb'
- 'lib/mastodon/cli/*.rb'

# Reason:
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsmodulelength
Expand All @@ -176,9 +176,7 @@ Rails/HttpStatus:
Rails/Exit:
Exclude:
- 'config/boot.rb'
- 'lib/mastodon/*_cli.rb'
- 'lib/mastodon/cli_helper.rb'
- 'lib/cli.rb'
- 'lib/mastodon/cli/*.rb'

# Reason: Some single letter camel case files shouldn't be split
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecfilepath
Expand Down
16 changes: 8 additions & 8 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,9 @@ Rails/SkipsModelValidations:
- 'db/post_migrate/20220617202502_migrate_roles.rb'
- 'db/post_migrate/20221101190723_backfill_admin_action_logs.rb'
- 'db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb'
- 'lib/cli.rb'
- 'lib/mastodon/accounts_cli.rb'
- 'lib/mastodon/maintenance_cli.rb'
- 'lib/mastodon/cli/accounts.rb'
- 'lib/mastodon/cli/main.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'spec/controllers/api/v1/admin/accounts_controller_spec.rb'
- 'spec/lib/activitypub/activity/follow_spec.rb'
- 'spec/services/follow_service_spec.rb'
Expand Down Expand Up @@ -929,7 +929,7 @@ Rails/WhereExists:
- 'app/validators/vote_validator.rb'
- 'app/workers/move_worker.rb'
- 'db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb'
- 'lib/mastodon/email_domain_blocks_cli.rb'
- 'lib/mastodon/cli/email_domain_blocks.rb'
- 'lib/tasks/tests.rake'
- 'spec/controllers/api/v1/accounts/notes_controller_spec.rb'
- 'spec/controllers/api/v1/tags_controller_spec.rb'
Expand Down Expand Up @@ -991,7 +991,7 @@ Style/FormatStringToken:
Exclude:
- 'app/models/privacy_policy.rb'
- 'config/initializers/devise.rb'
- 'lib/mastodon/maintenance_cli.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'lib/paperclip/color_extractor.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Expand Down Expand Up @@ -1436,9 +1436,9 @@ Style/GuardClause:
- 'db/post_migrate/20220704024901_migrate_settings_to_user_roles.rb'
- 'lib/devise/two_factor_ldap_authenticatable.rb'
- 'lib/devise/two_factor_pam_authenticatable.rb'
- 'lib/mastodon/accounts_cli.rb'
- 'lib/mastodon/maintenance_cli.rb'
- 'lib/mastodon/media_cli.rb'
- 'lib/mastodon/cli/accounts.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'lib/mastodon/cli/media.rb'
- 'lib/paperclip/attachment_extensions.rb'
- 'lib/tasks/repo.rake'

Expand Down
4 changes: 2 additions & 2 deletions bin/tootctl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
APP_PATH = File.expand_path('../config/application', __dir__)

require_relative '../config/boot'
require_relative '../lib/cli'
require_relative '../lib/mastodon/cli/main'

begin
Chewy.strategy(:mastodon) do
Mastodon::CLI.start(ARGV)
Mastodon::CLI::Main.start(ARGV)
end
rescue Interrupt
exit(130)
Expand Down
12 changes: 6 additions & 6 deletions lib/mastodon/accounts_cli.rb → lib/mastodon/cli/accounts.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

require 'set'
require_relative '../../config/boot'
require_relative '../../config/environment'
require_relative 'cli_helper'
require_relative '../../../config/boot'
require_relative '../../../config/environment'
require_relative 'helper'

module Mastodon
class AccountsCLI < Thor
include CLIHelper
module Mastodon::CLI
class Accounts < Thor
include Helper

def self.exit_on_failure?
true
Expand Down
12 changes: 6 additions & 6 deletions lib/mastodon/cache_cli.rb → lib/mastodon/cli/cache.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require_relative '../../config/boot'
require_relative '../../config/environment'
require_relative 'cli_helper'
require_relative '../../../config/boot'
require_relative '../../../config/environment'
require_relative 'helper'

module Mastodon
class CacheCLI < Thor
include CLIHelper
module Mastodon::CLI
class Cache < Thor
include Helper

def self.exit_on_failure?
true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

require 'concurrent'
require_relative '../../config/boot'
require_relative '../../config/environment'
require_relative 'cli_helper'
require_relative '../../../config/boot'
require_relative '../../../config/environment'
require_relative 'helper'

module Mastodon
class CanonicalEmailBlocksCLI < Thor
include CLIHelper
module Mastodon::CLI
class CanonicalEmailBlocks < Thor
include Helper

def self.exit_on_failure?
true
Expand Down
12 changes: 6 additions & 6 deletions lib/mastodon/domains_cli.rb → lib/mastodon/cli/domains.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

require 'concurrent'
require_relative '../../config/boot'
require_relative '../../config/environment'
require_relative 'cli_helper'
require_relative '../../../config/boot'
require_relative '../../../config/environment'
require_relative 'helper'

module Mastodon
class DomainsCLI < Thor
include CLIHelper
module Mastodon::CLI
class Domains < Thor
include Helper

def self.exit_on_failure?
true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

require 'concurrent'
require_relative '../../config/boot'
require_relative '../../config/environment'
require_relative 'cli_helper'
require_relative '../../../config/boot'
require_relative '../../../config/environment'
require_relative 'helper'

module Mastodon
class EmailDomainBlocksCLI < Thor
include CLIHelper
module Mastodon::CLI
class EmailDomainBlocks < Thor
include Helper

def self.exit_on_failure?
true
Expand Down
10 changes: 5 additions & 5 deletions lib/mastodon/emoji_cli.rb → lib/mastodon/cli/emoji.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require 'rubygems/package'
require_relative '../../config/boot'
require_relative '../../config/environment'
require_relative 'cli_helper'
require_relative '../../../config/boot'
require_relative '../../../config/environment'
require_relative 'helper'

module Mastodon
class EmojiCLI < Thor
module Mastodon::CLI
class Emoji < Thor
def self.exit_on_failure?
true
end
Expand Down
12 changes: 6 additions & 6 deletions lib/mastodon/feeds_cli.rb → lib/mastodon/cli/feeds.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require_relative '../../config/boot'
require_relative '../../config/environment'
require_relative 'cli_helper'
require_relative '../../../config/boot'
require_relative '../../../config/environment'
require_relative 'helper'

module Mastodon
class FeedsCLI < Thor
include CLIHelper
module Mastodon::CLI
class Feeds < Thor
include Helper
include Redisable

def self.exit_on_failure?
Expand Down
4 changes: 2 additions & 2 deletions lib/mastodon/cli_helper.rb → lib/mastodon/cli/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
Paperclip.options[:log] = false
Chewy.logger = dev_null

module Mastodon
module CLIHelper
module Mastodon::CLI
module Helper
def dry_run?
options[:dry_run]
end
Expand Down
10 changes: 5 additions & 5 deletions lib/mastodon/ip_blocks_cli.rb → lib/mastodon/cli/ip_blocks.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require 'rubygems/package'
require_relative '../../config/boot'
require_relative '../../config/environment'
require_relative 'cli_helper'
require_relative '../../../config/boot'
require_relative '../../../config/environment'
require_relative 'helper'

module Mastodon
class IpBlocksCLI < Thor
module Mastodon::CLI
class IpBlocks < Thor
def self.exit_on_failure?
true
end
Expand Down
Loading

0 comments on commit b6b4ea4

Please sign in to comment.