thoughtbot/paperclip

View on GitHub

Showing 1,010 of 1,010 total issues

Assignment Branch Condition size for expiring_url is too high. [15.81/15]
Open

      def expiring_url(time = (Time.now + 3600), style_name = default_style)
        time = convert_time(time)
        http_url_method = "get_#{scheme}_url"
        if path(style_name) && directory.files.respond_to?(http_url_method)
          expiring_url = directory.files.public_send(http_url_method, path(style_name), time)
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 default_url is too high. [15.13/15]
Open

    def default_url
      if attachment_options[:default_url].respond_to?(:call)
        attachment_options[:default_url].call(@attachment)
      elsif attachment_options[:default_url].is_a?(Symbol)
        @attachment.instance.send(attachment_options[:default_url])
Severity: Minor
Found in lib/paperclip/url_generator.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 extended is too high. [15.81/15]
Open

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

Method flush_writes has 38 lines of code (exceeds 25 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 1 hr to fix

    Method flush_deletes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def flush_deletes #:nodoc:
            @queued_for_delete.each do |path|
              begin
                log("deleting #{path}")
                FileUtils.rm(path) if File.exist?(path)
    Severity: Minor
    Found in lib/paperclip/storage/filesystem.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

    Method missing_attachments_styles has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.missing_attachments_styles
        current_styles = current_attachments_styles
        registered_styles = get_registered_attachments_styles
    
        Hash.new.tap do |missing_styles|
    Severity: Minor
    Found in lib/paperclip/missing_attachment_styles.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

    Method extended has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.extended base
            begin
              require 'fog'
            rescue LoadError => e
              e.message << " (You may need to install the fog gem)"
    Severity: Minor
    Found in lib/paperclip/storage/fog.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

    Method flush_writes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    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 - 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

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

            @queued_for_write.each do |style, file|
            retries = 0
              begin
                log("saving #{path(style)}")
                write_options = {
    Severity: Minor
    Found in lib/paperclip/storage/s3.rb 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.

    Method default_options has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.default_options
          @default_options ||= {
            :convert_options       => {},
            :default_style         => :original,
            :default_url           => "/:attachment/:style/missing.png",
    Severity: Minor
    Found in lib/paperclip/attachment.rb - About 1 hr to fix

      Method make has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def make
            src = @file
            filename = [@basename, @format ? ".#{@format}" : ""].join
            dst = TempfileFactory.new.generate(filename)
      
      
      Severity: Minor
      Found in lib/paperclip/thumbnail.rb - About 1 hr to fix

        Method flush_writes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        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 - About 55 mins 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

        Method resize_to has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        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 - About 55 mins 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

        Method validates_attachment has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        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 - About 55 mins 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

        Method post_process_style has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        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 - About 55 mins 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

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

                    klass_sym = klass.to_s.to_sym
                    missing_styles[klass_sym] ||= Hash.new
                    missing_styles[klass_sym][attachment_name.to_sym] ||= Array.new
                    missing_styles[klass_sym][attachment_name.to_sym].concat(missed.to_a)
                    missing_styles[klass_sym][attachment_name.to_sym].map!(&:to_s).sort!.map!(&:to_sym).uniq!
        Severity: Minor
        Found in lib/paperclip/missing_attachment_styles.rb and 1 other location - About 50 mins to fix
        lib/paperclip/missing_attachment_styles.rb on lines 41..45

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

        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

                  klass_sym = klass.to_s.to_sym
                  current_styles[klass_sym] ||= Hash.new
                  current_styles[klass_sym][attachment_name.to_sym] ||= Array.new
                  current_styles[klass_sym][attachment_name.to_sym] << style_name.to_sym
                  current_styles[klass_sym][attachment_name.to_sym].map!(&:to_s).sort!.map!(&:to_sym).uniq!
        Severity: Minor
        Found in lib/paperclip/missing_attachment_styles.rb and 1 other location - About 50 mins to fix
        lib/paperclip/missing_attachment_styles.rb on lines 69..73

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

        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 load_processor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def load_processor(name)
              if defined?(Rails.root) && Rails.root
                filename = "#{name.to_s.underscore}.rb"
                directories = %w(lib/paperclip lib/paperclip_processors)
        
        
        Severity: Minor
        Found in lib/paperclip/processor_helpers.rb - About 45 mins 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

        Method make has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def make
              src = @file
              filename = [@basename, @format ? ".#{@format}" : ""].join
              dst = TempfileFactory.new.generate(filename)
        
        
        Severity: Minor
        Found in lib/paperclip/thumbnail.rb - About 35 mins 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

        Method transformation_command has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        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 - About 35 mins 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