fredjean/middleman-s3_sync

View on GitHub
lib/middleman/s3_sync/resource.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Resource has 40 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Resource
      attr_accessor :path, :resource, :partial_s3_resource, :full_s3_resource, :content_type, :gzipped, :options

      CONTENT_MD5_KEY = 'x-amz-meta-content-md5'
      REDIRECT_KEY = 'x-amz-website-redirect-location'
Severity: Minor
Found in lib/middleman/s3_sync/resource.rb - About 5 hrs to fix

    Method status has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def status
            @status ||= if shunned?
                          :ignored
                        elsif directory?
                          if remote?
    Severity: Minor
    Found in lib/middleman/s3_sync/resource.rb - About 1 hr to fix

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

            def ignore!
              if options.verbose
                reason = if redirect?
                           :redirect
                         elsif directory?
      Severity: Minor
      Found in lib/middleman/s3_sync/resource.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 to_h has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def to_h
              attributes = {
                :key => key,
                :acl => options.acl,
                :content_type => content_type,
      Severity: Minor
      Found in lib/middleman/s3_sync/resource.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

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

            def update!
              local_content { |body|
                say_status "#{ANSI.blue{"Updating"}} #{remote_path}#{ gzipped ? ANSI.white {' (gzipped)'} : ''}"
                s3_resource.merge_attributes(to_h)
                s3_resource.body = body
      Severity: Minor
      Found in lib/middleman/s3_sync/resource.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