mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
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:
parent
be72b9d02e
commit
cdf794ecbf
5 changed files with 7 additions and 13 deletions
|
|
@ -92,6 +92,10 @@ Style/SpaceAroundOperators:
|
||||||
Style/SpaceInsideBrackets:
|
Style/SpaceInsideBrackets:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
# This cop enforces the use the shorthand for self-assignment.
|
||||||
|
Style/SelfAssignment:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
# Use single quotes unless there's string interpolation
|
# Use single quotes unless there's string interpolation
|
||||||
Style/StringLiterals:
|
Style/StringLiterals:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
|
||||||
|
|
@ -721,14 +721,6 @@ Style/RegexpLiteral:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'Guardfile'
|
- 'Guardfile'
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/SelfAssignment:
|
|
||||||
Exclude:
|
|
||||||
- 'app/models/event.rb'
|
|
||||||
- 'db/migrate/20141104131625_generate_username.rb'
|
|
||||||
- 'spec/support/save_feature_failures.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
# Offense count: 3
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ class Event < ActiveRecord::Base
|
||||||
def average_rating
|
def average_rating
|
||||||
@total_rating = 0
|
@total_rating = 0
|
||||||
votes.each do |vote|
|
votes.each do |vote|
|
||||||
@total_rating = @total_rating + vote.rating
|
@total_rating += vote.rating
|
||||||
end
|
end
|
||||||
@total = votes.size
|
@total = votes.size
|
||||||
@total_rating > 0 ? number_with_precision(@total_rating / @total.to_f, precision: 2, strip_insignificant_zeros: true) : 0
|
@total_rating > 0 ? number_with_precision(@total_rating / @total.to_f, precision: 2, strip_insignificant_zeros: true) : 0
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,7 @@ class GenerateUsername < ActiveRecord::Migration
|
||||||
TempUser.all.each do |user|
|
TempUser.all.each do |user|
|
||||||
if user.username.blank?
|
if user.username.blank?
|
||||||
username = user.email.split('@')[0]
|
username = user.email.split('@')[0]
|
||||||
if TempUser.find_by(username: username)
|
username += user.id.to_s if TempUser.find_by(username: username)
|
||||||
username = username + user.id.to_s
|
|
||||||
end
|
|
||||||
user.update_attributes(username: username)
|
user.update_attributes(username: username)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ RSpec.configure do |config|
|
||||||
config.after(:each, type: :feature) do
|
config.after(:each, type: :feature) do
|
||||||
example_filename = RSpec.current_example.full_description
|
example_filename = RSpec.current_example.full_description
|
||||||
example_filename = example_filename.tr(' ', '_')
|
example_filename = example_filename.tr(' ', '_')
|
||||||
example_filename = example_filename + '.html'
|
example_filename += '.html'
|
||||||
example_filename = File.expand_path(example_filename, Capybara.save_and_open_page_path)
|
example_filename = File.expand_path(example_filename, Capybara.save_and_open_page_path)
|
||||||
if RSpec.current_example.exception.present?
|
if RSpec.current_example.exception.present?
|
||||||
save_page(example_filename)
|
save_page(example_filename)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue