thoughtbot/paperclip

View on GitHub

Showing 30 of 1,009 total issues

Class Attachment has 68 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Attachment
    def self.default_options
      @default_options ||= {
        :convert_options       => {},
        :default_style         => :original,
Severity: Major
Found in lib/paperclip/attachment.rb - About 1 day to fix

    File attachment.rb has 427 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'uri'
    require 'paperclip/url_generator'
    require 'active_support/deprecation'
    require 'active_support/core_ext/string/inflections'
    
    
    Severity: Minor
    Found in lib/paperclip/attachment.rb - About 6 hrs to fix

      Method flush_writes has a Cognitive Complexity of 23 (exceeds 5 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 3 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 extended has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

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

      File s3.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Paperclip
        module Storage
          # Amazon's S3 file hosting service is a scalable, easy place to store files for
          # distribution. You can find out more about it at http://aws.amazon.com/s3
          #
      Severity: Minor
      Found in lib/paperclip/storage/s3.rb - About 2 hrs to fix

        Method extended has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def self.extended base
                begin
                  require "aws-sdk-s3"
                rescue LoadError => e
                  e.message << " (You may need to install the aws-sdk-s3 gem)"
        Severity: Minor
        Found in lib/paperclip/storage/s3.rb - About 1 hr to fix

          Method validate_each has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                def validate_each(record, attr_name, value)
                  base_attr_name = attr_name
                  attr_name = "#{attr_name}_file_size".to_sym
                  value = record.send(:read_attribute_for_validation, attr_name)
          
          
          Severity: Minor
          Found in lib/paperclip/validators/attachment_size_validator.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 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

            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 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 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 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

                Severity
                Category
                Status
                Source
                Language