carrierwaveuploader/carrierwave

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

Summary

Maintainability
C
1 day
Test Coverage

Method public_url has a Cognitive Complexity of 31 (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 24 methods (exceeds 20 allowed). Consider refactoring.
Open

      class File
        DEFAULT_S3_REGION = 'us-east-1'.freeze

        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 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?(fog_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

                        regional_host = 's3-accelerate.amazonaws.com' if @uploader.fog_aws_accelerate
      Severity: Major
      Found in lib/carrierwave/storage/fog.rb - About 45 mins to fix

        Method store has a Cognitive Complexity of 7 (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 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 acl_header has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

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