carrierwaveuploader/carrierwave

View on GitHub
lib/carrierwave/storage/fog.rb

Summary

Maintainability
D
1 day
Test Coverage

Method public_url has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

        def public_url
          encoded_path = encode_path(path)
          if host = @uploader.asset_host
            if host.respond_to? :call
              "#{host.call(self)}/#{encoded_path}"
Severity: Minor
Found in lib/carrierwave/storage/fog.rb - About 4 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

Class File has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

      class File
        DEFAULT_S3_REGION = 'us-east-1'

        include CarrierWave::Utilities::Uri
        include CarrierWave::Utilities::FileName
Severity: Minor
Found in lib/carrierwave/storage/fog.rb - About 2 hrs to fix

    Method public_url has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def public_url
              encoded_path = encode_path(path)
              if host = @uploader.asset_host
                if host.respond_to? :call
                  "#{host.call(self)}/#{encoded_path}"
    Severity: Minor
    Found in lib/carrierwave/storage/fog.rb - About 1 hr to fix

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

              def store(new_file)
                if new_file.is_a?(self.class)
                  new_file.copy_to(path)
                else
                  fog_file = new_file.to_file
      Severity: Minor
      Found in lib/carrierwave/storage/fog.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

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

              def acl_header
                if fog_provider == 'AWS'
                  { 'x-amz-acl' => @uploader.fog_public ? 'public-read' : 'private' }
                elsif fog_provider == "Google"
                  @uploader.fog_public ? { destination_predefined_acl: "publicRead" } : {}
      Severity: Minor
      Found in lib/carrierwave/storage/fog.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

                        s3_subdomain = @uploader.fog_aws_accelerate ? "s3-accelerate" : "s3"
      Severity: Major
      Found in lib/carrierwave/storage/fog.rb - About 45 mins to fix

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

                def authenticated_url(options = {})
                  if ['AWS', 'Google', 'Rackspace', 'OpenStack', 'AzureRM', 'Aliyun', 'backblaze'].include?(@uploader.fog_credentials[:provider])
                    # avoid a get by using local references
                    local_directory = connection.directories.new(:key => @uploader.fog_directory)
                    local_file = local_directory.files.new(:key => path)
        Severity: Minor
        Found in lib/carrierwave/storage/fog.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

        Avoid deeply nested control flow statements.
        Open

                          host   = case region
                                   when DEFAULT_S3_REGION, ''
                                     's3.amazonaws.com'
                                   else
                                     "s3.#{region}.amazonaws.com"
        Severity: Major
        Found in lib/carrierwave/storage/fog.rb - About 45 mins to fix

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

                def clean_cache!(seconds)
                  connection.directories.new(
                    :key    => uploader.fog_directory,
                    :public => uploader.fog_public
                  ).files.all(:prefix => uploader.cache_dir).each do |file|
          Severity: Minor
          Found in lib/carrierwave/storage/fog.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