carrierwaveuploader/carrierwave

View on GitHub

Showing 48 of 53 total issues

Method process! has 27 lines of code (exceeds 25 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 1 hr to fix

    Method cache has 26 lines of code (exceeds 25 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 1 hr to fix

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

          def identified_content_type
            with_io do |io|
              mimetype_by_magic = Marcel::Magic.by_magic(io)
              mimetype_by_path = Marcel::Magic.by_path(path)
      
      
      Severity: Minor
      Found in lib/carrierwave/sanitized_file.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

      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

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

            def check_extension_allowlist!(new_file)
              allowlist = extension_allowlist
              if !allowlist && respond_to?(:extension_whitelist) && extension_whitelist
                ActiveSupport::Deprecation.warn "#extension_whitelist is deprecated, use #extension_allowlist instead." unless instance_variable_defined?(:@extension_whitelist_warned)
                @extension_whitelist_warned = true
      Severity: Minor
      Found in lib/carrierwave/uploader/extension_allowlist.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

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

            def check_content_type_allowlist!(new_file)
              allowlist = content_type_allowlist
              if !allowlist && respond_to?(:content_type_whitelist) && content_type_whitelist
                ActiveSupport::Deprecation.warn "#content_type_whitelist is deprecated, use #content_type_allowlist instead." unless instance_variable_defined?(:@content_type_whitelist_warned)
                @content_type_whitelist_warned = true
      Severity: Minor
      Found in lib/carrierwave/uploader/content_type_allowlist.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

        Consider simplifying this complex logical expression.
        Open

              if file.is_a?(Hash)
                @file = file["tempfile"] || file[:tempfile]
                @original_filename = file["filename"] || file[:filename]
                @declared_content_type = file["content_type"] || file[:content_type] || file["type"] || file[:type]
              else
        Severity: Major
        Found in lib/carrierwave/sanitized_file.rb - About 40 mins to fix

          Method resize_and_pad has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def resize_and_pad(width, height, background=nil, gravity='centre', alpha=nil)
          Severity: Minor
          Found in lib/carrierwave/processing/vips.rb - About 35 mins to fix

            Method resize_and_pad has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def resize_and_pad(width, height, background=:transparent, gravity='Center', combine_options: {}, &block)
            Severity: Minor
            Found in lib/carrierwave/processing/mini_magick.rb - About 35 mins to fix

              Method resize_and_pad has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def resize_and_pad(width, height, background=nil, gravity='centre', alpha=nil, combine_options: {})
              Severity: Minor
              Found in lib/carrierwave/processing/vips.rb - About 35 mins to fix

                Method crop has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def crop(left, top, width, height, combine_options: {}, &block)
                Severity: Minor
                Found in lib/carrierwave/processing/mini_magick.rb - About 35 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 minimagick! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def minimagick!(block = nil)
                        builder = ImageProcessing::MiniMagick.source(current_path)
                        builder = yield(builder)
                  
                        result = builder.call
                  Severity: Minor
                  Found in lib/carrierwave/processing/mini_magick.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 resolve_dimensions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def resolve_dimensions(*dimensions)
                        dimensions.map do |value|
                          next value unless value.instance_of?(Proc)
                          value.arity >= 1 ? value.call(self) : value.call
                        end
                  Severity: Minor
                  Found in lib/carrierwave/processing/mini_magick.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 cache! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def cache!(new_file = file)
                          new_file = CarrierWave::SanitizedFile.new(new_file)
                          return if new_file.empty?
                  
                          raise CarrierWave::FormNotMultipart if new_file.is_path? && ensure_multipart_form
                  Severity: Minor
                  Found in lib/carrierwave/uploader/cache.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 process_uri has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def process_uri(source)
                          uri = Addressable::URI.parse(source)
                          uri.host = uri.normalized_host
                          # Perform decode first, as the path is likely to be already encoded
                          uri.path = encode_path(decode_uri(uri.path)) if uri.path =~ CarrierWave::Utilities::Uri::PATH_UNSAFE
                  Severity: Minor
                  Found in lib/carrierwave/downloader/base.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 resolve_dimensions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def resolve_dimensions(*dimensions)
                        dimensions.map do |value|
                          next value unless value.instance_of?(Proc)
                          value.arity >= 1 ? value.call(self) : value.call
                        end
                  Severity: Minor
                  Found in lib/carrierwave/processing/vips.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 manipulate! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def manipulate!
                        cache_stored_file! if !cached?
                        image = ::MiniMagick::Image.open(current_path)
                  
                        image = yield(image)
                  Severity: Minor
                  Found in lib/carrierwave/processing/mini_magick.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

                  Severity
                  Category
                  Status
                  Source
                  Language