carrierwaveuploader/carrierwave

View on GitHub

Showing 48 of 48 total issues

Method process! has a Cognitive Complexity of 33 (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 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

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 SanitizedFile has 26 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 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

      Class Mounter has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Mounter #:nodoc:
          attr_reader :column, :record, :remote_urls, :integrity_errors,
            :processing_errors, :download_errors
          attr_accessor :remove, :remote_request_headers
      
      
      Severity: Minor
      Found in lib/carrierwave/mounter.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 store! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def store!(new_file=nil)
                cache!(new_file) if new_file && ((@cache_id != parent_cache_id) || @cache_id.nil?)
                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 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 remove_previous has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def remove_previous(before=nil, after=nil)
                after ||= []
                return unless before
          
                # both 'before' and 'after' can be string when 'mount_on' option is set
          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 reset_config has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def reset_config
                    configure do |config|
                      config.permissions = 0644
                      config.directory_permissions = 0755
                      config.storage_engines = {
          Severity: Minor
          Found in lib/carrierwave/uploader/configuration.rb - About 1 hr to fix

            Method build_version has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def build_version(name, options)
                      if !versions.has_key?(name)
                        uploader = Class.new(self)
                        const_set("Uploader#{uploader.object_id}".tr('-', '_'), uploader)
                        uploader.version_names += [name]
            Severity: Minor
            Found in lib/carrierwave/uploader/versions.rb - About 1 hr to fix

              Method version_exists? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                    def version_exists?(name)
                      name = name.to_sym
              
                      return false unless self.class.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 marcel_magic_by_mime_type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def marcel_magic_by_mime_type
                    return unless path
              
                    type = File.open(path) do |file|
                      Marcel::Magic.by_magic(file).try(:type)
              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 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
                        ActiveSupport::Deprecation.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 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
                        ActiveSupport::Deprecation.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 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 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

              Severity
              Category
              Status
              Source
              Language