glitch-soc/mastodon

View on GitHub
app/models/media_attachment.rb

Summary

Maintainability
C
7 hrs
Test Coverage

File media_attachment.rb has 301 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MediaAttachment < ApplicationRecord
  self.inheritance_column = nil

  include Attachmentable

Severity: Minor
Found in app/models/media_attachment.rb - About 3 hrs to fix

    Class MediaAttachment has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class MediaAttachment < ApplicationRecord
      self.inheritance_column = nil
    
      include Attachmentable
    
    
    Severity: Minor
    Found in app/models/media_attachment.rb - About 3 hrs to fix

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

        def check_video_dimensions
          return unless (video? || gifv?) && file.queued_for_write[:original].present?
      
          movie = ffmpeg_data(file.queued_for_write[:original].path)
      
      
      Severity: Minor
      Found in app/models/media_attachment.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 file_styles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def file_styles(attachment)
            if attachment.instance.file_content_type == 'image/gif' || VIDEO_CONVERTIBLE_MIME_TYPES.include?(attachment.instance.file_content_type)
              VIDEO_CONVERTED_STYLES
            elsif IMAGE_CONVERTIBLE_MIME_TYPES.include?(attachment.instance.file_content_type)
              IMAGE_CONVERTED_STYLES
      Severity: Minor
      Found in app/models/media_attachment.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