thoughtbot/paperclip

View on GitHub

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        module Validators
          class AttachmentContentTypeValidator < ActiveModel::EachValidator
            def initialize(options)
              options[:allow_nil] = true unless options.has_key?(:allow_nil)
              super
      lib/paperclip/validators/attachment_file_name_validator.rb on lines 2..75

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 166.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        module Validators
          class AttachmentFileNameValidator < ActiveModel::EachValidator
            def initialize(options)
              options[:allow_nil] = true unless options.has_key?(:allow_nil)
              super
      Severity: Major
      Found in lib/paperclip/validators/attachment_file_name_validator.rb and 1 other location - About 4 hrs to fix
      lib/paperclip/validators/attachment_content_type_validator.rb on lines 2..84

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 166.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Severity
        Category
        Status
        Source
        Language