thoughtbot/paperclip

View on GitHub
lib/paperclip/io_adapters/abstract_adapter.rb

Summary

Maintainability
A
0 mins
Test Coverage

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

require 'active_support/core_ext/module/delegation'

Line is too long. [84/80]
Open

      Paperclip.log("Link failed with #{e.message}; copying link #{src} to #{dest}")

Line is too long. [121/80]
Open

    delegate :binmode, :binmode?, :close, :close!, :closed?, :eof?, :path, :readbyte, :rewind, :unlink, :to => :@tempfile

Redundant self detected.
Open

      "#{self.class}: #{self.original_filename}"

This cop checks for redundant uses of self.

self is only needed when:

  • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

    Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

    Example:

    def bar :baz end

    def foo(bar) self.bar # resolves name clash with argument end

    def foo2 bar = 1 self.bar # resolves name clash with local variable end

  • Calling an attribute writer to prevent an local variable assignment

    attr_writer :bar

    def foo self.bar= 1 # Make sure above attr writer is called end

Special cases:

We allow uses of self with operators because it would be awkward otherwise.

Use the new Ruby 1.9 hash syntax.
Open

    delegate :binmode, :binmode?, :close, :close!, :closed?, :eof?, :path, :readbyte, :rewind, :unlink, :to => :@tempfile

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