thoughtbot/paperclip

View on GitHub

Showing 1,006 of 1,009 total issues

Module has too many lines. [275/100]
Open

    module S3
      def self.extended base
        begin
          require "aws-sdk-s3"
        rescue LoadError => e
Severity: Minor
Found in lib/paperclip/storage/s3.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Module has too many lines. [179/100]
Open

    module Fog
      def self.extended base
        begin
          require 'fog'
        rescue LoadError => e
Severity: Minor
Found in lib/paperclip/storage/fog.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Module has too many lines. [116/100]
Open

  module Interpolations
    extend self
    ID_PARTITION_LIMIT = 1_000_000_000

    # Hash assignment of interpolations. Included only for compatibility,
Severity: Minor
Found in lib/paperclip/interpolations.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for extended is too high. [71.72/15]
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 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. [100/25]
Open

namespace :paperclip do
  desc "Refreshes both metadata and thumbnails."
  task :refresh => ["paperclip:refresh:metadata", "paperclip:refresh:thumbnails"]

  namespace :refresh do
Severity: Minor
Found in lib/tasks/paperclip.rake 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.

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

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

      namespace :refresh do
        desc "Regenerates thumbnails for a given CLASS (and optional ATTACHMENT and STYLES splitted by comma)."
        task :thumbnails => :environment do
          klass = Paperclip::Task.obtain_class
          names = Paperclip::Task.obtain_attachments(klass)
    Severity: Minor
    Found in lib/tasks/paperclip.rake 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 post_process_style is too high. [32.57/15]
    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 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. [30.48/15]
    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 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. [30.43/15]
    Open

        def initialize(file, options = {}, attachment = nil)
          super
    
          geometry             = options[:geometry].to_s
          @crop                = geometry[-1,1] == '#'
    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

    Assignment Branch Condition size for missing_attachments_styles is too high. [30.95/15]
    Open

      def self.missing_attachments_styles
        current_styles = current_attachments_styles
        registered_styles = get_registered_attachments_styles
    
        Hash.new.tap do |missing_styles|

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

    Assignment Branch Condition size for current_attachments_styles is too high. [28.18/15]
    Open

      def self.current_attachments_styles
        Hash.new.tap do |current_styles|
          Paperclip::AttachmentRegistry.each_definition do |klass, attachment_name, attachment_attributes|
            # TODO: is it even possible to take into account Procs?
            next if attachment_attributes[:styles].kind_of?(Proc)

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

        def make
          src = @file
          filename = [@basename, @format ? ".#{@format}" : ""].join
          dst = TempfileFactory.new.generate(filename)
    
    
    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 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

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

      Severity
      Category
      Status
      Source
      Language