thoughtbot/paperclip

View on GitHub

Showing 1,009 of 1,009 total issues

Line is too long. [92/80]
Open

    #   See Paperclip::Attachment#interpolate for more information on variable interpolaton.
Severity: Minor
Found in lib/paperclip/storage/filesystem.rb by rubocop

Line is too long. [119/80]
Open

            @options[:path]  = @options[:path].gsub(/:url/, @options[:url]).gsub(/\A:rails_root\/public\/system\//, '')
Severity: Minor
Found in lib/paperclip/storage/fog.rb by rubocop

Use the new Ruby 1.9 hash syntax.
Open

              :body         => file,
Severity: Minor
Found in lib/paperclip/storage/fog.rb by rubocop

This cop checks hash literal syntax.

It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

A separate offense is registered for each problematic pair.

The supported styles are:

  • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
  • hash_rockets - forces use of hash rockets for all hashes
  • nomixedkeys - simply checks for hashes with mixed syntaxes
  • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

Example: EnforcedStyle: ruby19 (default)

# bad
{:a => 2}
{b: 1, :c => 2}

# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden

Example: EnforcedStyle: hash_rockets

# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}

# good
{:a => 1, :b => 2}

Example: EnforcedStyle: nomixedkeys

# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}

# good
{:a => 1, :b => 2}
{c: 1, d: 2}

Example: EnforcedStyle: ruby19nomixed_keys

# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets

# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}

Prefer using YAML.safe_load over YAML.load.
Open

          YAML::load(ERB.new(File.read(creds)).result)
Severity: Minor
Found in lib/paperclip/storage/fog.rb by rubocop

This cop checks for the use of YAML class methods which have potential security issues leading to remote code execution when loading from an untrusted source.

Example:

# bad
YAML.load("--- foo")

# good
YAML.safe_load("--- foo")
YAML.dump("foo")

Line is too long. [88/80]
Open

        permissions = { :default => permissions } unless permissions.respond_to?(:merge)
Severity: Minor
Found in lib/paperclip/storage/s3.rb by rubocop

Use the new Ruby 1.9 hash syntax.
Open

            write_options.merge!(:storage_class => storage_class) if storage_class
Severity: Minor
Found in lib/paperclip/storage/s3.rb by rubocop

This cop checks hash literal syntax.

It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

A separate offense is registered for each problematic pair.

The supported styles are:

  • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
  • hash_rockets - forces use of hash rockets for all hashes
  • nomixedkeys - simply checks for hashes with mixed syntaxes
  • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

Example: EnforcedStyle: ruby19 (default)

# bad
{:a => 2}
{b: 1, :c => 2}

# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden

Example: EnforcedStyle: hash_rockets

# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}

# good
{:a => 1, :b => 2}

Example: EnforcedStyle: nomixedkeys

# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}

# good
{:a => 1, :b => 2}
{c: 1, d: 2}

Example: EnforcedStyle: ruby19nomixed_keys

# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets

# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}

Line is too long. [91/80]
Open

              break if File.exist?(path) # Ruby 1.9.2 does not raise if the removal failed.
Severity: Minor
Found in lib/paperclip/storage/filesystem.rb by rubocop

Line is too long. [108/80]
Open

          (@options[:fog_host] =~ /%d/) ? @options[:fog_host] % (path(style).hash % 4) : @options[:fog_host]
Severity: Minor
Found in lib/paperclip/storage/fog.rb by rubocop

Use =~ in places where the MatchData returned by #match will not be used.
Open

          unless @options[:url].to_s.match(/\A:fog.*url\z/)
Severity: Minor
Found in lib/paperclip/storage/fog.rb by rubocop

This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

Example:

# bad
do_something if str.match(/regex/)
while regex.match('str')
  do_something
end

# good
method(str =~ /regex/)
return value unless regex =~ 'str'

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Open

          if fog_credentials[:provider] == 'AWS'
Severity: Minor
Found in lib/paperclip/storage/fog.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Extra empty line detected at class body beginning.
Open


    def generate(name = random_name)
Severity: Minor
Found in lib/paperclip/tempfile_factory.rb by rubocop

This cops checks if empty lines around the bodies of classes match the configuration.

Example: EnforcedStyle: empty_lines

# good

class Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

class Foo
  class Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
class Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

class Foo
  def bar
    # ...
  end
end

Use =~ in places where the MatchData returned by #match will not be used.
Open

        delimiter_char = url.match(/\?.+=/) ? '&' : '?'
Severity: Minor
Found in lib/paperclip/url_generator.rb by rubocop

This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

Example:

# bad
do_something if str.match(/regex/)
while regex.match('str')
  do_something
end

# good
method(str =~ /regex/)
return value unless regex =~ 'str'

Line is too long. [87/80]
Open

        @s3_host_alias = @s3_host_alias.call(self) if @s3_host_alias.respond_to?(:call)
Severity: Minor
Found in lib/paperclip/storage/s3.rb by rubocop

Line is too long. [82/80]
Open

        warn("#{e} - cannot copy #{path(style)} to local file #{local_dest_path}")
Severity: Minor
Found in lib/paperclip/storage/s3.rb by rubocop

Use the new Ruby 1.9 hash syntax.
Open

              :acl => s3_permissions(style)
Severity: Minor
Found in lib/paperclip/storage/s3.rb by rubocop

This cop checks hash literal syntax.

It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

A separate offense is registered for each problematic pair.

The supported styles are:

  • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
  • hash_rockets - forces use of hash rockets for all hashes
  • nomixedkeys - simply checks for hashes with mixed syntaxes
  • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

Example: EnforcedStyle: ruby19 (default)

# bad
{:a => 2}
{b: 1, :c => 2}

# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden

Example: EnforcedStyle: hash_rockets

# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}

# good
{:a => 1, :b => 2}

Example: EnforcedStyle: nomixedkeys

# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}

# good
{:a => 1, :b => 2}
{c: 1, d: 2}

Example: EnforcedStyle: ruby19nomixed_keys

# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets

# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}

Favor a normal unless-statement over a modifier clause in a multiline statement.
Open

        Paperclip.interpolates(:s3_alias_url) do |attachment, style|
          protocol = attachment.s3_protocol(style, true)
          host = attachment.s3_host_alias
          path = attachment.path(style).
            split("/")[attachment.s3_prefixes_in_alias..-1].
Severity: Minor
Found in lib/paperclip/storage/s3.rb by rubocop

Checks for uses of if/unless modifiers with multiple-lines bodies.

Example:

# bad
{
  result: 'this should not happen'
} unless cond

# good
{ result: 'ok' } if cond

Favor a normal unless-statement over a modifier clause in a multiline statement.
Open

        Paperclip.interpolates(:asset_host) do |attachment, style|
          "#{attachment.path(style).sub(%r{\A/}, "".freeze)}"
        end unless Paperclip::Interpolations.respond_to? :asset_host
Severity: Minor
Found in lib/paperclip/storage/s3.rb by rubocop

Checks for uses of if/unless modifiers with multiple-lines bodies.

Example:

# bad
{
  result: 'this should not happen'
} unless cond

# good
{ result: 'ok' } if cond

Line is too long. [90/80]
Open

    #   By default this places the files in the app's public directory which can be served
Severity: Minor
Found in lib/paperclip/storage/filesystem.rb by rubocop

Line is too long. [95/80]
Open

    # * +override_file_permissions+: This allows you to override the file permissions for files
Severity: Minor
Found in lib/paperclip/storage/filesystem.rb by rubocop

Use the new Ruby 1.9 hash syntax.
Open

          directory.files.new(:key => path).destroy
Severity: Minor
Found in lib/paperclip/storage/fog.rb by rubocop

This cop checks hash literal syntax.

It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

A separate offense is registered for each problematic pair.

The supported styles are:

  • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
  • hash_rockets - forces use of hash rockets for all hashes
  • nomixedkeys - simply checks for hashes with mixed syntaxes
  • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

Example: EnforcedStyle: ruby19 (default)

# bad
{:a => 2}
{b: 1, :c => 2}

# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden

Example: EnforcedStyle: hash_rockets

# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}

# good
{:a => 1, :b => 2}

Example: EnforcedStyle: nomixedkeys

# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}

# good
{:a => 1, :b => 2}
{c: 1, d: 2}

Example: EnforcedStyle: ruby19nomixed_keys

# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets

# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}
Severity
Category
Status
Source
Language