maa123/mastodon

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

Summary

Maintainability
F
4 days
Test Coverage

Method remove_orphans has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

    def remove_orphans
      progress        = create_progress_bar(nil)
      reclaimed_bytes = 0
      removed         = 0
      prefix          = options[:prefix]
Severity: Minor
Found in lib/mastodon/cli/media.rb - About 1 day 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 remove has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    def remove
      if options[:prune_profiles] && options[:remove_headers]
        say('--prune-profiles and --remove-headers should not be specified simultaneously', :red, true)
        exit(1)
      end
Severity: Minor
Found in lib/mastodon/cli/media.rb - About 6 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 remove_orphans has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def remove_orphans
      progress        = create_progress_bar(nil)
      reclaimed_bytes = 0
      removed         = 0
      prefix          = options[:prefix]
Severity: Major
Found in lib/mastodon/cli/media.rb - About 3 hrs to fix

    File media.rb has 295 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative 'base'
    
    module Mastodon::CLI
      class Media < Base
        include ActionView::Helpers::NumberHelper
    Severity: Minor
    Found in lib/mastodon/cli/media.rb - About 3 hrs to fix

      Method refresh has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def refresh
            if options[:status]
              scope = MediaAttachment.where(status_id: options[:status])
            elsif options[:account]
              username, domain = options[:account].split('@')
      Severity: Minor
      Found in lib/mastodon/cli/media.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 lookup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def lookup(url)
            path = Addressable::URI.parse(url).path
      
            path_segments = path.split('/')[2..]
            path_segments.delete('cache')
      Severity: Minor
      Found in lib/mastodon/cli/media.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 remove has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def remove
            if options[:prune_profiles] && options[:remove_headers]
              say('--prune-profiles and --remove-headers should not be specified simultaneously', :red, true)
              exit(1)
            end
      Severity: Minor
      Found in lib/mastodon/cli/media.rb - About 1 hr to fix

        Method refresh has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def refresh
              if options[:status]
                scope = MediaAttachment.where(status_id: options[:status])
              elsif options[:account]
                username, domain = options[:account].split('@')
        Severity: Minor
        Found in lib/mastodon/cli/media.rb - About 1 hr to fix

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

              def lookup(url)
                path = Addressable::URI.parse(url).path
          
                path_segments = path.split('/')[2..]
                path_segments.delete('cache')
          Severity: Minor
          Found in lib/mastodon/cli/media.rb - About 1 hr to fix

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

                def preload_records_from_mixed_objects(objects)
                  preload_map = Hash.new { |hash, key| hash[key] = [] }
            
                  objects.map do |object|
                    segments = object.key.split('/')
            Severity: Minor
            Found in lib/mastodon/cli/media.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

            There are no issues that match your filters.

            Category
            Status