thoughtbot/paperclip

View on GitHub

Showing 1,009 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.

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

    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

      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

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

      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

      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

        Severity
        Category
        Status
        Source
        Language