wahanegi/vibereport

View on GitHub
app/models/emotion.rb

Summary

Maintainability
A
0 mins
Test Coverage

Uniqueness validation should have a unique index on the database column.
Open

  validates :word, presence: true, length: { in: 2..15 }, uniqueness: { scope: :category, case_sensitive: false }
Severity: Minor
Found in app/models/emotion.rb by rubocop

Redundant self detected.
Open

  before_save { self.word&.downcase! }
Severity: Minor
Found in app/models/emotion.rb by rubocop

Checks for redundant uses of self.

The usage of 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.

  • Calling an attribute writer to prevent a local variable assignment.

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

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

Example:

# bad
def foo(bar)
  self.baz
end

# good
def foo(bar)
  self.bar  # Resolves name clash with the argument.
end

def foo
  bar = 1
  self.bar  # Resolves name clash with the local variable.
end

def foo
  %w[x y z].select do |bar|
    self.bar == bar  # Resolves name clash with argument of the block.
  end
end

Do not use :: for method calls.
Open

  validates :category, inclusion: { in: Emotion::categories }
Severity: Minor
Found in app/models/emotion.rb by rubocop

Checks for methods invoked via the :: operator instead of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).

Example:

# bad
Timeout::timeout(500) { do_something }
FileUtils::rmdir(dir)
Marshal::dump(obj)

# good
Timeout.timeout(500) { do_something }
FileUtils.rmdir(dir)
Marshal.dump(obj)

There are no issues that match your filters.

Category
Status