GeekPark/gpk_account

View on GitHub
app/models/setting/identify.rb

Summary

Maintainability
A
0 mins
Test Coverage

Use find_by instead of dynamic find_by_id. (https://github.com/bbatsov/rails-style-guide#find_by)
Open

    User.find_by_id(user_id)
Severity: Minor
Found in app/models/setting/identify.rb by rubocop

This cop checks dynamic find_by_* methods. Use find_by instead of dynamic method. See. https://github.com/bbatsov/rails-style-guide#find_by

Example:

# bad
User.find_by_name(name)

# bad
User.find_by_name_and_email(name)

# bad
User.find_by_email!(name)

# good
User.find_by(name: name)

# good
User.find_by(name: name, email: email)

# good
User.find_by!(email: email)

Avoid using update_attribute because it skips validations. (http://guides.rubyonrails.org/active_record_validations.html#skipping-validations)
Open

    user.update_attribute(:is_old, false) if type == 'email' && user.is_old?
Severity: Minor
Found in app/models/setting/identify.rb by rubocop

This cop checks for the use of methods which skip validations which are listed in http://guides.rubyonrails.org/active_record_validations.html#skipping-validations

Example:

# bad
Article.first.decrement!(:view_count)
DiscussionBoard.decrement_counter(:post_count, 5)
Article.first.increment!(:view_count)
DiscussionBoard.increment_counter(:post_count, 5)
person.toggle :active
product.touch
Billing.update_all("category = 'authorized', author = 'David'")
user.update_attribute(website: 'example.com')
user.update_columns(last_request_at: Time.current)
Post.update_counters 5, comment_count: -1, action_count: 1

# good
user.update_attributes(website: 'example.com')
FileUtils.touch('file')

There are no issues that match your filters.

Category
Status