thoughtbot/paperclip

View on GitHub

Showing 62 of 999 total issues

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

    module S3
      def self.extended base
        begin
          require 'aws-sdk'
        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. [178/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.

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

    Assignment Branch Condition size for extended is too high. [83.95/15]
    Open

          def self.extended base
            begin
              require 'aws-sdk'
            rescue LoadError => e
              e.message << " (You may need to install the aws-sdk 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

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

      module Interpolations
        extend self
    
        # Hash assignment of interpolations. Included only for compatibility,
        # and is not intended for normal use.
    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.

    File attachment.rb has 416 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 extended has a Cognitive Complexity of 24 (exceeds 5 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: 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 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

      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 post_process_style is too high. [29.55/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

      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. [26.55/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

      File s3.rb has 289 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

        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

        Severity
        Category
        Status
        Source