thoughtbot/paperclip

View on GitHub

Showing 999 of 999 total issues

Assignment Branch Condition size for content_type_extension is too high. [21/15]
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 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

Assignment Branch Condition size for validates_attachment is too high. [20.15/15]
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 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 extended has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

    Assignment Branch Condition size for initialize is too high. [19.65/15]
    Open

        def initialize name, definition, attachment
          @name = name
          @attachment = attachment
          if definition.is_a? Hash
            @geometry = definition.delete(:geometry)
    Severity: Minor
    Found in lib/paperclip/style.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

    Assignment Branch Condition size for flush_writes is too high. [19.39/15]
    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 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

    Assignment Branch Condition size for should_validate_attachment_size is too high. [18.71/15]
    Open

        def should_validate_attachment_size name, options = {}
          klass   = self.name.gsub(/Test$/, '').constantize
          min     = options[:greater_than] || (options[:in] && options[:in].first) || 0
          max     = options[:less_than]    || (options[:in] && options[:in].last)  || (1.0/0)
          range   = (min..max)
    Severity: Minor
    Found in shoulda_macros/paperclip.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

    Assignment Branch Condition size for resize_to is too high. [18.41/15]
    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 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

    Assignment Branch Condition size for scale_to is too high. [18.03/15]
    Open

        def scale_to(new_geometry)
          scale = [new_geometry.width.to_f / self.width.to_f , new_geometry.height.to_f / self.height.to_f].min
          Paperclip::Geometry.new((self.width * scale).round, (self.height * scale).round)
        end
    Severity: Minor
    Found in lib/paperclip/geometry.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

    Assignment Branch Condition size for cropping is too high. [18.11/15]
    Open

        def cropping dst, ratio, scale
          if ratio.horizontal? || ratio.square?
            "%dx%d+%d+%d" % [ dst.width, dst.height, 0, (self.height * scale - dst.height) / 2 ]
          else
            "%dx%d+%d+%d" % [ dst.width, dst.height, (self.width * scale - dst.width) / 2, 0 ]
    Severity: Minor
    Found in lib/paperclip/geometry.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

    Assignment Branch Condition size for validate_each is too high. [18.92/15]
    Open

          def validate_each(record, attribute, value)
            base_attribute = attribute.to_sym
            attribute = "#{attribute}_content_type".to_sym
            value = record.send :read_attribute_for_validation, attribute
    
    

    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

    Assignment Branch Condition size for validate_each is too high. [18.92/15]
    Open

          def validate_each(record, attribute, value)
            base_attribute = attribute.to_sym
            attribute = "#{attribute}_file_name".to_sym
            value = record.send :read_attribute_for_validation, attribute
    
    

    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

    Assignment Branch Condition size for expiring_url is too high. [18.68/15]
    Open

          def expiring_url(time = (Time.now + 3600), style_name = default_style)
            time = convert_time(time)
            http_url_method = "get_#{scheme}_url"
            if path(style_name) && directory.files.respond_to?(http_url_method)
              expiring_url = directory.files.public_send(http_url_method, path(style_name), time)
    Severity: Minor
    Found in lib/paperclip/storage/fog.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

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

    Gem::Specification.new do |s|
      s.name              = "paperclip"
      s.version           = Paperclip::VERSION
      s.platform          = Gem::Platform::RUBY
      s.author            = "Jon Yurek"
    Severity: Minor
    Found in paperclip.gemspec 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.

    Assignment Branch Condition size for initialize is too high. [17.8/15]
    Open

        def initialize(name, instance, options = {})
          @name              = name.to_sym
          @name_string       = name.to_s
          @instance          = instance
    
    
    Severity: Minor
    Found in lib/paperclip/attachment.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

    Assignment Branch Condition size for queue_all_for_delete is too high. [17.58/15]
    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 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

    Assignment Branch Condition size for run is too high. [16.76/15]
    Open

        def run(cmd, arguments = "", interpolation_values = {}, local_options = {})
          command_path = options[:command_path]
          cocaine_path_array = Cocaine::CommandLine.path.try(:split, Cocaine::OS.path_separator)
          Cocaine::CommandLine.path = [cocaine_path_array, command_path].flatten.compact.uniq
          if logging? && (options[:log_command] || local_options[:log_command])
    Severity: Minor
    Found in lib/paperclip/helpers.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

    Assignment Branch Condition size for transformation_command is too high. [16.64/15]
    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 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 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

    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

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

          def public_url(style = default_style)
            if @options[:fog_host]
              "#{dynamic_fog_host_for_style(style)}/#{path(style)}"
            else
              if fog_credentials[:provider] == 'AWS'
    Severity: Minor
    Found in lib/paperclip/storage/fog.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

    Severity
    Category
    Status
    Source