thoughtbot/paperclip

View on GitHub

Showing 65 of 1,009 total issues

Assignment Branch Condition size for default_url is too high. [15.13/15]
Open

    def default_url
      if attachment_options[:default_url].respond_to?(:call)
        attachment_options[:default_url].call(@attachment)
      elsif attachment_options[:default_url].is_a?(Symbol)
        @attachment.instance.send(attachment_options[:default_url])
Severity: Minor
Found in lib/paperclip/url_generator.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method flush_writes has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def flush_writes #:nodoc:
        @queued_for_write.each do |style, file|
        retries = 0
          begin
            log("saving #{path(style)}")
Severity: Minor
Found in lib/paperclip/storage/s3.rb - About 1 hr to fix

    Method flush_deletes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def flush_deletes #:nodoc:
            @queued_for_delete.each do |path|
              begin
                log("deleting #{path}")
                FileUtils.rm(path) if File.exist?(path)
    Severity: Minor
    Found in lib/paperclip/storage/filesystem.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 post_process_style has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def post_process_style(name, style) #:nodoc:
          begin
            raise RuntimeError.new("Style #{name} has no processors defined.") if style.processors.blank?
            intermediate_files = []
            original = @queued_for_write[:original]
    Severity: Minor
    Found in lib/paperclip/attachment.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 missing_attachments_styles has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.missing_attachments_styles
        current_styles = current_attachments_styles
        registered_styles = get_registered_attachments_styles
    
        Hash.new.tap do |missing_styles|
    Severity: Minor
    Found in lib/paperclip/missing_attachment_styles.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 flush_writes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def flush_writes #:nodoc:
            @queued_for_write.each do |style_name, file|
              FileUtils.mkdir_p(File.dirname(path(style_name)))
              begin
                move_file(file.path, path(style_name))
    Severity: Minor
    Found in lib/paperclip/storage/filesystem.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 extended has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.extended base
            begin
              require 'fog'
            rescue LoadError => e
              e.message << " (You may need to install the fog gem)"
    Severity: Minor
    Found in lib/paperclip/storage/fog.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

    Block has too many lines. [34/25]
    Open

            @queued_for_write.each do |style, file|
            retries = 0
              begin
                log("saving #{path(style)}")
                write_options = {
    Severity: Minor
    Found in lib/paperclip/storage/s3.rb by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Method make has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def make
          src = @file
          filename = [@basename, @format ? ".#{@format}" : ""].join
          dst = TempfileFactory.new.generate(filename)
    
    
    Severity: Minor
    Found in lib/paperclip/thumbnail.rb - About 1 hr to fix

      Method default_options has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.default_options
            @default_options ||= {
              :convert_options       => {},
              :default_style         => :original,
              :default_url           => "/:attachment/:style/missing.png",
      Severity: Minor
      Found in lib/paperclip/attachment.rb - About 1 hr to fix

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

              def validates_attachment(*attributes)
                options = attributes.extract_options!.dup
        
                Paperclip::Validators.constants.each do |constant|
                  if constant.to_s =~ /\AAttachment(.+)Validator\z/
        Severity: Minor
        Found in lib/paperclip/validators.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 flush_writes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def flush_writes
                for style, file in @queued_for_write do
                  log("saving #{path(style)}")
                  retried = false
                  begin
        Severity: Minor
        Found in lib/paperclip/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 resize_to has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def resize_to(geometry)
              new_geometry = Paperclip::Geometry.parse geometry
              case new_geometry.modifier
              when '!', '#'
                new_geometry
        Severity: Minor
        Found in lib/paperclip/geometry.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 load_processor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def load_processor(name)
              if defined?(Rails.root) && Rails.root
                filename = "#{name.to_s.underscore}.rb"
                directories = %w(lib/paperclip lib/paperclip_processors)
        
        
        Severity: Minor
        Found in lib/paperclip/processor_helpers.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 unlink_files has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def unlink_files(files)
              Array(files).each do |file|
                file.close unless file.closed?
        
                begin
        Severity: Minor
        Found in lib/paperclip/attachment.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 make has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def make
              src = @file
              filename = [@basename, @format ? ".#{@format}" : ""].join
              dst = TempfileFactory.new.generate(filename)
        
        
        Severity: Minor
        Found in lib/paperclip/thumbnail.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 queue_all_for_delete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def queue_all_for_delete #:nodoc:
              return if !file?
              unless @options[:preserve_files]
                @queued_for_delete += [:original, *styles.keys].uniq.map do |style|
                  path(style) if exists?(style)
        Severity: Minor
        Found in lib/paperclip/attachment.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 transformation_command has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def transformation_command
              scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)
              trans = []
              trans << "-coalesce" if animated?
              trans << "-auto-orient" if auto_orient
        Severity: Minor
        Found in lib/paperclip/thumbnail.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 fog_public has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def fog_public(style = default_style)
                if @options.key?(:fog_public)
                  value = @options[:fog_public]
                  if value.respond_to?(:key?) && value.key?(style)
                    value[style]
        Severity: Minor
        Found in lib/paperclip/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 content_type_extension has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def content_type_extension attachment, style_name
              mime_type = MIME::Types[attachment.content_type]
              extensions_for_mime_type = unless mime_type.empty?
                mime_type.first.extensions
              else
        Severity: Minor
        Found in lib/paperclip/interpolations.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

        Severity
        Category
        Status
        Source
        Language