glitch-soc/mastodon

View on GitHub
lib/mastodon/cli/maintenance.rb

Summary

Maintainability
F
3 days
Test Coverage

File maintenance.rb has 604 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative 'base'

module Mastodon::CLI
  class Maintenance < Base
    MIN_SUPPORTED_VERSION = 2019_10_01_213028
Severity: Major
Found in lib/mastodon/cli/maintenance.rb - About 1 day to fix

    Class Maintenance has 45 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Maintenance < Base
        MIN_SUPPORTED_VERSION = 2019_10_01_213028
        MAX_SUPPORTED_VERSION = 2023_10_23_105620
    
        # Stubs to enjoy ActiveRecord queries while not depending on a particular
    Severity: Minor
    Found in lib/mastodon/cli/maintenance.rb - About 6 hrs to fix

      Method merge_with! has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

            def merge_with!(other_account)
              # Since it's the same remote resource, the remote resource likely
              # already believes we are following/blocking, so it's safe to
              # re-attribute the relationships too. However, during the presence
              # of the index bug users could have *also* followed the reference
      Severity: Minor
      Found in lib/mastodon/cli/maintenance.rb - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method merge_with! has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def merge_with!(other_account)
              # Since it's the same remote resource, the remote resource likely
              # already believes we are following/blocking, so it's safe to
              # re-attribute the relationships too. However, during the presence
              # of the index bug users could have *also* followed the reference
      Severity: Major
      Found in lib/mastodon/cli/maintenance.rb - About 2 hrs to fix

        Method merge_statuses! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def merge_statuses!(main_status, duplicate_status)
              owned_classes = [Favourite, Mention, Poll]
              owned_classes << Bookmark if db_table_exists?(:bookmarks)
              owned_classes.each do |klass|
                klass.where(status_id: duplicate_status.id).find_each do |record|
        Severity: Minor
        Found in lib/mastodon/cli/maintenance.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method deduplicate_local_accounts! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def deduplicate_local_accounts!(scope)
              accounts = scope.order(id: :desc).includes(:account_stat, :user).to_a
        
              say "Multiple local accounts were found for username '#{accounts.first.username}'.", :yellow
              say 'All those accounts are distinct accounts but only the most recently-created one is fully-functional.', :yellow
        Severity: Minor
        Found in lib/mastodon/cli/maintenance.rb - About 1 hr to fix

          Method deduplicate_accounts! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def deduplicate_accounts!
                remove_index_if_exists!(:accounts, 'index_accounts_on_username_and_domain_lower')
          
                say 'Deduplicating accounts… for local accounts, you will be asked to chose which account to keep unchanged.'
          
          
          Severity: Minor
          Found in lib/mastodon/cli/maintenance.rb - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          There are no issues that match your filters.

          Category
          Status