SpeciesFileGroup/taxonworks

View on GitHub
app/models/identifier/global/uuid.rb

Summary

Maintainability
A
0 mins
Test Coverage

Prefer self[:attr] = val over write_attribute(:attr, val).
Open

    write_attribute(:identifier, SecureRandom.uuid)

This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

Example:

# bad
x = read_attribute(:attr)
write_attribute(:attr, val)

# good
x = self[:attr]
self[:attr] = val

There are no issues that match your filters.

Category
Status