From 4a9c971ec77b725417ef0926df3b86bc8cdcc6e7 Mon Sep 17 00:00:00 2001 From: gotens1211 Date: Wed, 1 Feb 2017 20:47:35 +0530 Subject: [PATCH] Enable Style/SpaceAroundOperators Rubocop Cleared all the offenses for Style/SpaceAroundOperators Added a description for the Style/SpaceAroundOperators Rubocop. --- .rubocop.yml | 5 ++++- .rubocop_todo.yml | 16 ---------------- app/controllers/application_controller.rb | 2 +- app/models/conference.rb | 12 ++++++------ app/models/event.rb | 2 +- app/models/target.rb | 2 +- app/models/ticket.rb | 4 ++-- ...clude_cfp_in_splash_add_column_include_cfp.rb | 2 +- .../20150417050953_add_url_to_commercial.rb | 2 +- .../20151018152439_create_programs_table.rb | 2 +- spec/models/conference_spec.rb | 6 +++--- 11 files changed, 21 insertions(+), 34 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7da4d8d5..497d45e8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -101,7 +101,10 @@ Metrics/ClassLength: Style/BracesAroundHashParameters: Enabled: true -# +# Checks that operators have space around them, except for ** which should not have surrounding space. +Style/SpaceAroundOperators: + Enabled: true + Style/CaseEquality: Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e81bc65c..da6d3bb2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -594,22 +594,6 @@ Style/SpaceAroundBlockParameters: Style/SpaceAroundEqualsInParameterDefault: Enabled: false -# Offense count: 12 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Style/SpaceAroundOperators: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/models/conference.rb' - - 'app/models/datatable.rb' - - 'app/models/event.rb' - - 'app/models/target.rb' - - 'app/models/ticket.rb' - - 'db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb' - - 'db/migrate/20150417050953_add_url_to_commercial.rb' - - 'db/migrate/20151018152439_create_programs_table.rb' - - 'spec/models/conference_spec.rb' - # Offense count: 223 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9646b86c..9cd0aca7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -37,7 +37,7 @@ class ApplicationController < ActionController::Base end def get_conferences - @conferences =Conference.all + @conferences = Conference.all end def current_ability diff --git a/app/models/conference.rb b/app/models/conference.rb index 31c61d73..4416d656 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -160,7 +160,7 @@ class Conference < ActiveRecord::Base result[state] = pad_array_left_not_kumulative(start_week, values) end end - result['Weeks'] = weeks > 0 ? (1..weeks).to_a : 0 + result['Weeks'] = weeks > 0 ? (1..weeks).to_a : 0 end result end @@ -343,8 +343,8 @@ class Conference < ActiveRecord::Base # * +hash+ -> hash def registration_distribution reg = registrations.includes(:user) - attended_value = { 'value' => reg.where(attended: true).count, 'color' => 'magenta' } - not_attended_value = { 'value' => reg.where.not(attended: true).count, 'color' => 'blue' } + attended_value = { 'value' => reg.where(attended: true).count, 'color' => 'magenta' } + not_attended_value = { 'value' => reg.where.not(attended: true).count, 'color' => 'blue' } { 'Attended' => attended_value, 'Not attended' => not_attended_value } end @@ -360,7 +360,7 @@ class Conference < ActiveRecord::Base def affiliation_distribution counted_affiliations = registrations.joins(:user).group(:affiliation).count result = {} - i=1 + i = 1 others = 0 none = 0 counted_affiliations.each do |key, value| @@ -625,7 +625,7 @@ class Conference < ActiveRecord::Base def hours_from_start_time(start_hour, end_hour) current_time = Time.find_zone(timezone).now current_hour = current_time.strftime('%H').to_i - (start_hour..(end_hour-1)).cover?(current_hour) ? current_hour - start_hour : 0 + (start_hour..(end_hour - 1)).cover?(current_hour) ? current_hour - start_hour : 0 end private @@ -641,7 +641,7 @@ class Conference < ActiveRecord::Base # consecutive colors clearly different. def next_color_component(component, i) big_prime_numbers = {r: 113, g: 67, b: 151} - ((i*big_prime_numbers[component])%239 + 16).to_s(16) + ((i * big_prime_numbers[component]) % 239 + 16).to_s(16) end after_create do diff --git a/app/models/event.rb b/app/models/event.rb index d2446847..1eebb0b0 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -135,7 +135,7 @@ class Event < ActiveRecord::Base def process_confirmation if program.conference.email_settings.send_on_confirmed_without_registration? && - program.conference.email_settings.confirmed_without_registration_body && + program.conference.email_settings.confirmed_without_registration_body && program.conference.email_settings.confirmed_without_registration_subject if program.conference.registrations.where(user_id: submitter.id).first.nil? Mailbot.confirm_reminder_mail(self).deliver_later diff --git a/app/models/target.rb b/app/models/target.rb index 2de7c757..6581c48d 100644 --- a/app/models/target.rb +++ b/app/models/target.rb @@ -58,7 +58,7 @@ class Target < ActiveRecord::Base numerator = conference.current_program_minutes end - progress = (numerator / target_count.to_f * 100).round(0).to_s + progress = (numerator / target_count.to_f * 100).round(0).to_s result = { 'target_name' => to_s, 'campaign_name' => campaign.name, diff --git a/app/models/ticket.rb b/app/models/ticket.rb index ba8157e2..8c93f5c9 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -22,7 +22,7 @@ class Ticket < ActiveRecord::Base def tickets_paid(user) paid_tickets = quantity_bought_by(user, paid: true) unpaid_tickets = quantity_bought_by(user, paid: false) - "#{paid_tickets}/#{paid_tickets+unpaid_tickets}" + "#{paid_tickets}/#{paid_tickets + unpaid_tickets}" end def quantity_bought_by(user, paid: false) @@ -44,7 +44,7 @@ class Ticket < ActiveRecord::Base tickets.each do |ticket| price = ticket.total_price(user, paid: paid) if result - result += price unless price.zero? + result += price unless price.zero? else result = price end diff --git a/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb b/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb index 8c44344b..2f794f75 100644 --- a/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb +++ b/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb @@ -3,7 +3,7 @@ class MigrateDataRemoveColumnIncludeCfpInSplashAddColumnIncludeCfp < ActiveRecor self.table_name = 'conferences' end - class TempCallForPaper< ActiveRecord::Base + class TempCallForPaper < ActiveRecord::Base self.table_name = 'call_for_papers' end diff --git a/db/migrate/20150417050953_add_url_to_commercial.rb b/db/migrate/20150417050953_add_url_to_commercial.rb index 6df2bb81..56adf34f 100644 --- a/db/migrate/20150417050953_add_url_to_commercial.rb +++ b/db/migrate/20150417050953_add_url_to_commercial.rb @@ -1,5 +1,5 @@ class AddUrlToCommercial < ActiveRecord::Migration - class TempCommercial< ActiveRecord::Base + class TempCommercial < ActiveRecord::Base self.table_name = 'commercials' end diff --git a/db/migrate/20151018152439_create_programs_table.rb b/db/migrate/20151018152439_create_programs_table.rb index aa52a33c..4a71edb4 100644 --- a/db/migrate/20151018152439_create_programs_table.rb +++ b/db/migrate/20151018152439_create_programs_table.rb @@ -1,4 +1,4 @@ -class CreateProgramsTable< ActiveRecord::Migration +class CreateProgramsTable < ActiveRecord::Migration class TempConference < ActiveRecord::Base self.table_name = 'conferences' end diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index e16373bd..8520a978 100755 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -853,7 +853,7 @@ describe Conference do conference = create(:conference) event = create(:event, program: conference.program) event.reject!(@options) - result = { 'Rejected' => { 'value' => 1, 'color' => '#FF0000' } } + result = { 'Rejected' => { 'value' => 1, 'color' => '#FF0000' } } expect(conference.event_distribution).to eq(result) end @@ -863,7 +863,7 @@ describe Conference do event = create(:event, program: conference.program) event.accept!(@options) event.confirm! - result = { 'Confirmed' => { 'value' => 1, 'color' => '#00FF00' } } + result = { 'Confirmed' => { 'value' => 1, 'color' => '#00FF00' } } expect(conference.event_distribution).to eq(result) end @@ -872,7 +872,7 @@ describe Conference do event = create(:event, program: conference.program) event.accept!(@options) event.cancel! - result = { 'Canceled' => { 'value' => 1, 'color' => '#848484' } } + result = { 'Canceled' => { 'value' => 1, 'color' => '#848484' } } expect(conference.event_distribution).to eq(result) end