carrierwaveuploader/carrierwave

View on GitHub

Showing 53 of 53 total issues

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

      def process!(new_file=nil)
        return unless enable_processing

        with_callbacks(:process, new_file) do
          self.class.processors.each do |method, args, condition, condition_type|
Severity: Minor
Found in lib/carrierwave/uploader/processing.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 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 Mounter has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Mounter # :nodoc:
    class Single < Mounter # :nodoc
      def identifier
        uploaders.first&.identifier
      end
Severity: Minor
Found in lib/carrierwave/mounter.rb - About 3 hrs to fix

    Class SanitizedFile has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class SanitizedFile
        include CarrierWave::Utilities::FileName
    
        attr_reader :file
    
    
    Severity: Minor
    Found in lib/carrierwave/sanitized_file.rb - About 3 hrs to fix

      Class File has 25 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 manipulate! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def manipulate!(options={}, &block)
              cache_stored_file! if !cached?
        
              read_block = create_info_block(options[:read])
              image = ::Magick::Image.read(current_path, &read_block)
        Severity: Minor
        Found in lib/carrierwave/processing/rmagick.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 cache has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def cache(new_files)
              return if !new_files.is_a?(Array) && new_files.blank?
              old_uploaders = uploaders
              @uploaders = new_files.map do |new_file|
                handle_error do
        Severity: Minor
        Found in lib/carrierwave/mounter.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 url has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def url(options = {})
                if file.respond_to?(:url)
                  tmp_url = file.method(:url).arity.zero? ? file.url : file.url(options)
                  return tmp_url if tmp_url.present?
                end
        Severity: Minor
        Found in lib/carrierwave/uploader/url.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 read has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def read(*args)
              if @content
                if args.empty?
                  @content
                else
        Severity: Minor
        Found in lib/carrierwave/sanitized_file.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 reset_config has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def reset_config
                  configure do |config|
                    config.permissions = 0o644
                    config.directory_permissions = 0o755
                    config.storage_engines = {
        Severity: Minor
        Found in lib/carrierwave/uploader/configuration.rb - About 1 hr 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 check_dimensions! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def check_dimensions!(new_file)
                    # NOTE: Skip the check for resized images
                    return if version_name.present?
                    return unless width_range || height_range
            
            
            Severity: Minor
            Found in lib/carrierwave/uploader/dimension.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 store! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def store!(new_file=nil)
                    cache!(new_file) if new_file && !cached?
                    if !cache_only && @file && @cache_id
                      with_callbacks(:store, new_file) do
                        new_file = storage.store!(@file)
            Severity: Minor
            Found in lib/carrierwave/uploader/store.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 version_active? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def version_active?(name)
                    name = name.to_sym
            
                    return false unless versions.has_key?(name)
            
            
            Severity: Minor
            Found in lib/carrierwave/uploader/versions.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 download has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def download(url, remote_headers = {})
                    @current_download_retry_count = 0
                    headers = remote_headers.
                      reverse_merge('User-Agent' => "CarrierWave/#{CarrierWave::VERSION}")
                    uri = process_uri(url.to_s)
            Severity: Minor
            Found in lib/carrierwave/downloader/base.rb - About 1 hr to fix

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

                    def check_extension_denylist!(new_file)
                      denylist = extension_denylist
                      if !denylist && respond_to?(:extension_blacklist) && extension_blacklist
                        CarrierWave.deprecator.warn "#extension_blacklist is deprecated, use #extension_denylist instead." unless instance_variable_defined?(:@extension_blacklist_warned)
                        @extension_blacklist_warned = true
              Severity: Minor
              Found in lib/carrierwave/uploader/extension_denylist.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 handle_error has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def handle_error
                    yield
                  rescue CarrierWave::DownloadError => e
                    @download_errors << e
                    raise e unless option(:ignore_download_errors)
              Severity: Minor
              Found in lib/carrierwave/mounter.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 check_content_type_denylist! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def check_content_type_denylist!(new_file)
                      denylist = content_type_denylist
                      if !denylist && respond_to?(:content_type_blacklist) && content_type_blacklist
                        CarrierWave.deprecator.warn "#content_type_blacklist is deprecated, use #content_type_denylist instead." unless instance_variable_defined?(:@content_type_blacklist_warned)
                        @content_type_blacklist_warned = true
              Severity: Minor
              Found in lib/carrierwave/uploader/content_type_denylist.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 size has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def size
                    if is_path?
                      exists? ? File.size(path) : 0
                    elsif @file.respond_to?(:size)
                      @file.size
              Severity: Minor
              Found in lib/carrierwave/sanitized_file.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 download has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def download(url, remote_headers = {})
                      @current_download_retry_count = 0
                      headers = remote_headers.
                        reverse_merge('User-Agent' => "CarrierWave/#{CarrierWave::VERSION}")
                      uri = process_uri(url.to_s)
              Severity: Minor
              Found in lib/carrierwave/downloader/base.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

              Severity
              Category
              Status
              Source
              Language