glitch-soc/mastodon

View on GitHub
app/models/status.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Status has 61 methods (exceeds 20 allowed). Consider refactoring.
Open

class Status < ApplicationRecord
  include Cacheable
  include Discard::Model
  include Paginable
  include RateLimitable
Severity: Major
Found in app/models/status.rb - About 1 day to fix

    File status.rb has 391 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Status < ApplicationRecord
      include Cacheable
      include Discard::Model
      include Paginable
      include RateLimitable
    Severity: Minor
    Found in app/models/status.rb - About 5 hrs to fix

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

          def reload_stale_associations!(cached_items)
            account_ids = []
      
            cached_items.each do |item|
              account_ids << item.account_id
      Severity: Minor
      Found in app/models/status.rb - About 2 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 set_conversation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_conversation
          self.thread = thread.reblog if thread&.reblog?
      
          self.reply = !(in_reply_to_id.nil? && thread.nil?) unless reply
      
      
      Severity: Minor
      Found in app/models/status.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 from_text has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_text(text)
            return [] if text.blank?
      
            text.scan(FetchLinkCardService::URL_PATTERN).map(&:second).uniq.filter_map do |url|
              status = if TagManager.instance.local_url?(url)
      Severity: Minor
      Found in app/models/status.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 set_visibility has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_visibility
          self.visibility = reblog.visibility if reblog? && visibility.nil?
          self.visibility = (account.locked? ? :private : :public) if visibility.nil?
        end
      Severity: Minor
      Found in app/models/status.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