Add Style/SelfAssignment Rubocop cop

The cop enforces use of self assignment operator E.g. a=a+2 gets
written as a+=2. Also the offenses listed in rubocop.todo.yml
have been corrected automatically with the --auto-correct option.
Fixes issue #1531
This commit is contained in:
divyanshumehta 2017-06-12 22:37:45 +05:30
parent be72b9d02e
commit cdf794ecbf
5 changed files with 7 additions and 13 deletions

View file

@ -115,7 +115,7 @@ class Event < ActiveRecord::Base
def average_rating
@total_rating = 0
votes.each do |vote|
@total_rating = @total_rating + vote.rating
@total_rating += vote.rating
end
@total = votes.size
@total_rating > 0 ? number_with_precision(@total_rating / @total.to_f, precision: 2, strip_insignificant_zeros: true) : 0