lib/fog/aws/requests/storage/get_object.rb

Summary

Maintainability
D
2 days
Test Coverage
C
74%

Method get_object has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

        def get_object(bucket_name, object_name, options = {}, &block)
          version_id = options.delete('versionId')

          unless bucket_name
            raise ArgumentError.new('bucket_name is required')
Severity: Minor
Found in lib/fog/aws/requests/storage/get_object.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 byte_ranges has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

        def byte_ranges(http_range, size)
          # See <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35>
          return nil unless http_range
          ranges = []
          http_range.split(/,\s*/).each do |range_spec|
Severity: Minor
Found in lib/fog/aws/requests/storage/get_object.rb - About 3 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 get_object has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def get_object(bucket_name, object_name, options = {}, &block)
          version_id = options.delete('versionId')

          unless bucket_name
            raise ArgumentError.new('bucket_name is required')
Severity: Major
Found in lib/fog/aws/requests/storage/get_object.rb - About 3 hrs to fix

    Method get_object has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def get_object(bucket_name, object_name, options = {}, &block)
              unless bucket_name
                raise ArgumentError.new('bucket_name is required')
              end
              unless object_name
    Severity: Minor
    Found in lib/fog/aws/requests/storage/get_object.rb - About 1 hr to fix

      Method get_object has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def get_object(bucket_name, object_name, options = {}, &block)
                unless bucket_name
                  raise ArgumentError.new('bucket_name is required')
                end
                unless object_name
      Severity: Minor
      Found in lib/fog/aws/requests/storage/get_object.rb - About 55 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

      Avoid deeply nested control flow statements.
      Open

                        case key
                        when 'Cache-Control', 'Content-Disposition', 'Content-Encoding', 'Content-Length', 'Content-MD5', 'Content-Type', 'ETag', 'Expires', 'Last-Modified', /^x-amz-meta-/
                          response.headers[key] = value
                        end
      Severity: Major
      Found in lib/fog/aws/requests/storage/get_object.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                          unless ranges.nil? || ranges.empty?
                            response.status = 206
                            body = body[ranges.first]
                          end
        Severity: Major
        Found in lib/fog/aws/requests/storage/get_object.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                            while remaining > 0
                              chunk = data.read([remaining, Excon::CHUNK_SIZE].min)
                              block.call(chunk, remaining, total_bytes)
                              remaining -= Excon::CHUNK_SIZE
                            end
          Severity: Major
          Found in lib/fog/aws/requests/storage/get_object.rb - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status