thoughtbot/paperclip

View on GitHub

Showing 1,009 of 1,009 total issues

Assignment Branch Condition size for s3_interface is too high. [23.02/15]
Open

      def s3_interface
        @s3_interface ||= begin
          config = { region: s3_region }

          if using_http_proxy?
Severity: Minor
Found in lib/paperclip/storage/s3.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. [22.2/15]
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)

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 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 flush_writes is too high. [20.32/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 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

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

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. The cop can be configured to ignore blocks passed to certain methods.

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 id_partition is too high. [17.29/15]
Open

    def id_partition attachment, style_name
      case id = attachment.instance.id
      when Integer
        if id < ID_PARTITION_LIMIT
          ("%09d".freeze % id).scan(/\d{3}/).join("/".freeze)
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

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

    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]
          terrapin_path_array = Terrapin::CommandLine.path.try(:split, Terrapin::OS.path_separator)
          Terrapin::CommandLine.path = [terrapin_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

    Severity
    Category
    Status
    Source
    Language