glitch-soc/mastodon

View on GitHub
app/services/post_status_service.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class PostStatusService has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class PostStatusService < BaseService
  include Redisable
  include LanguagesHelper

  MIN_SCHEDULE_OFFSET = 5.minutes.freeze
Severity: Minor
Found in app/services/post_status_service.rb - About 2 hrs to fix

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

      def preprocess_attributes!
        fill_blank_text!
        @sensitive    = (@options[:sensitive].nil? ? @account.user&.setting_default_sensitive : @options[:sensitive]) || @options[:spoiler_text].present?
        @visibility   = @options[:visibility] || @account.user&.setting_default_privacy
        @visibility   = :unlisted if @visibility&.to_sym == :public && @account.silenced?
    Severity: Minor
    Found in app/services/post_status_service.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def call(account, options = {})
        @account     = account
        @options     = options
        @text        = @options[:text] || ''
        @in_reply_to = @options[:thread]
    Severity: Minor
    Found in app/services/post_status_service.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 fill_blank_text! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def fill_blank_text!
        return unless @text.blank? && @options[:spoiler_text].present?
    
        @text = begin
          if @media&.any?(&:video?) || @media&.any?(&:gifv?)
    Severity: Minor
    Found in app/services/post_status_service.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 validate_media! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def validate_media!
        if @options[:media_ids].blank? || !@options[:media_ids].is_a?(Enumerable)
          @media = []
          return
        end
    Severity: Minor
    Found in app/services/post_status_service.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