glitch-soc/mastodon

View on GitHub
app/workers/move_worker.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

  def copy_account_notes!
    AccountNote.where(target_account: @source_account).find_each do |note|
      text = I18n.with_locale(note.account.user&.locale.presence || I18n.default_locale) do
        I18n.t('move_handler.copy_account_note_text', acct: @source_account.acct)
      end
Severity: Minor
Found in app/workers/move_worker.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 rewrite_follows! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def rewrite_follows!
    num_moved = 0

    # First, approve pending follow requests for the new account,
    # this allows correctly processing list memberships with pending
Severity: Minor
Found in app/workers/move_worker.rb - About 1 hr to fix

    Method perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform(source_account_id, target_account_id)
        @source_account = Account.find(source_account_id)
        @target_account = Account.find(target_account_id)
    
        if @target_account.local? && @source_account.local?
    Severity: Minor
    Found in app/workers/move_worker.rb - About 45 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

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

      def carry_blocks_over!
        @source_account.blocked_by_relationships.where(account: Account.local).find_each do |block|
          unless block.account.blocking?(@target_account) || block.account.following?(@target_account)
            BlockService.new.call(block.account, @target_account)
            add_account_note_if_needed!(block.account, 'move_handler.carry_blocks_over_text')
    Severity: Minor
    Found in app/workers/move_worker.rb - About 35 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

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

      def carry_mutes_over!
        @source_account.muted_by_relationships.where(account: Account.local).find_each do |mute|
          MuteService.new.call(mute.account, @target_account, notifications: mute.hide_notifications) unless mute.account.muting?(@target_account) || mute.account.following?(@target_account)
          add_account_note_if_needed!(mute.account, 'move_handler.carry_mutes_over_text')
        rescue => e
    Severity: Minor
    Found in app/workers/move_worker.rb - About 35 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

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

      def rewrite_follows!
        num_moved = 0
    
        # First, approve pending follow requests for the new account,
        # this allows correctly processing list memberships with pending
    Severity: Minor
    Found in app/workers/move_worker.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