thoughtbot/paperclip

View on GitHub
lib/paperclip/has_attached_file.rb

Summary

Maintainability
A
0 mins
Test Coverage

Align the parameters of a method call if they span more than one line.
Open

          :if => ->(instance){ instance.send(name).dirty? }
Severity: Minor
Found in lib/paperclip/has_attached_file.rb by rubocop

Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
Open

        :post_process, :"#{@name}_post_process")
Severity: Minor
Found in lib/paperclip/has_attached_file.rb by rubocop

This cop checks that the closing brace in a method call is either on the same line as the last method argument, or a new line.

When using the symmetrical (default) style:

If a method call's opening brace is on the same line as the first argument of the call, then the closing brace should be on the same line as the last argument of the call.

If an method call's opening brace is on the line above the first argument of the call, then the closing brace should be on the line below the last argument of the call.

When using the new_line style:

The closing brace of a multi-line method call must be on the line after the last argument of the call.

When using the same_line style:

The closing brace of a multi-line method call must be on the same line as the last argument of the call.

Example:

  # symmetrical: bad
  # new_line: good
  # same_line: bad
  foo(a,
    b
  )

  # symmetrical: bad
  # new_line: bad
  # same_line: good
  foo(
    a,
    b)

  # symmetrical: good
  # new_line: bad
  # same_line: good
  foo(a,
    b)

  # symmetrical: good
  # new_line: good
  # same_line: bad
  foo(
    a,
    b
  )

Use !empty? instead of length > 0.
Open

        if args.length > 0
Severity: Minor
Found in lib/paperclip/has_attached_file.rb by rubocop

This cop checks for receiver.length == 0 predicates and the negated versions receiver.length > 0 and receiver.length != 0. These can be replaced with receiver.empty? and !receiver.empty? respectively.

Example:

# bad
[1, 2, 3].length == 0
0 == "foobar".length
hash.size > 0

# good
[1, 2, 3].empty?
"foobar".empty?
!hash.empty?

Unused block argument - value. If it's necessary, use _ or _value as an argument name to indicate that it won't be used.
Open

      @klass.send(:validates_each, @name) do |record, attr, value|
Severity: Minor
Found in lib/paperclip/has_attached_file.rb by rubocop

This cop checks for unused block arguments.

Example:

#good

do_something do |used, unused|
  puts used
end

do_something do
  puts :foo
end

define_method(:foo) do |_bar|
  puts :baz
end

# bad

do_something do |used, _unused|
  puts used
end

do_something do |bar|
  puts :foo
end

define_method(:foo) do |bar|
  puts :baz
end

Space missing to the left of {.
Open

          :if => ->(instance){ instance.send(name).dirty? }
Severity: Minor
Found in lib/paperclip/has_attached_file.rb by rubocop

Unused block argument - attr. If it's necessary, use _ or _attr as an argument name to indicate that it won't be used.
Open

      @klass.send(:validates_each, @name) do |record, attr, value|
Severity: Minor
Found in lib/paperclip/has_attached_file.rb by rubocop

This cop checks for unused block arguments.

Example:

#good

do_something do |used, unused|
  puts used
end

do_something do
  puts :foo
end

define_method(:foo) do |_bar|
  puts :baz
end

# bad

do_something do |used, _unused|
  puts used
end

do_something do |bar|
  puts :foo
end

define_method(:foo) do |bar|
  puts :baz
end

Use the new Ruby 1.9 hash syntax.
Open

          :if => ->(instance){ instance.send(name).dirty? }
Severity: Minor
Found in lib/paperclip/has_attached_file.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'"

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

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

Example:

"EnforcedStyle => 'hash_rockets'"

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

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

Example:

"EnforcedStyle => 'no_mixed_keys'"

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

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

Example:

"EnforcedStyle => 'ruby19_no_mixed_keys'"

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

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

There are no issues that match your filters.

Category
Status