diff --git a/.rubocop.yml b/.rubocop.yml index dbd68f69..235aa49a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -80,6 +80,34 @@ Lint/UselessAssignment: Lint/Void: Enabled: true +# Align the elements of a hash literal if they span more than one line +Style/AlignHash: + Enabled: true + +# Align the parameters of a method call if they span more than one line +Style/AlignParameters: + Enabled: true + +# Use && instead of and, use || instead of or +Style/AndOr: + Enabled: true + +# avoid deep blocks nesting +Style/BlockNesting: + Max: 4 + +# use do instead of {...} in multiline blocks +Style/Blocks: + Enabled: true + +# avoid redundunt curly braces when it is obvious that hash is used +Style/BracesAroundHashParameters: + Enabled: true + +# +Style/CaseEquality: + Enabled: true + AllCops: Include: - '**/Rakefile' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 318072cf..e453a5a8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -5,42 +5,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. -Style/AlignHash: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/AlignParameters: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -Style/AndOr: - Enabled: false - -# Offense count: 1 -Style/BlockNesting: - Max: 4 - -# Offense count: 2 -# Cop supports --auto-correct. -Style/Blocks: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/BracesAroundHashParameters: - Enabled: false - -# Offense count: 1 -Style/CaseEquality: - Enabled: false - # Offense count: 20 # Configuration parameters: EnforcedStyle, SupportedStyles. Style/ClassAndModuleChildren: diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index b5685bff..c98b9892 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -128,7 +128,7 @@ module Admin day_ticket_count = @tickets.where('supporter_registrations.created_at LIKE ? AND supporter_levels.title LIKE ?', - "%#{day}%", "%#{level.title}%").count + "%#{day}%", "%#{level.title}%").count index = @tickets_time.index { |v| v['key'] == "#{level.title}" } @tickets_time[index]['values'] << { 'label' => "#{day}", 'value' => day_ticket_count } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2a27b803..0219a4ca 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base helper_method :date_string def store_location - session[:return_to] = request.fullpath if request.get? and controller_name != "user_sessions" and controller_name != "sessions" + session[:return_to] = request.fullpath if request.get? && controller_name != "user_sessions" && controller_name != "sessions" end def after_sign_in_path_for(resource) diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb index a54fc2a4..9c366eb5 100644 --- a/app/controllers/event_attachments_controller.rb +++ b/app/controllers/event_attachments_controller.rb @@ -66,11 +66,11 @@ class EventAttachmentsController < ApplicationController respond_to do |format| if @upload.save - format.html { + format.html do render json: [@upload.to_jq_upload].to_json, content_type: 'text/html', layout: false - } + end format.json do render json: [@upload.to_jq_upload].to_json, status: :created, location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index 365d8bf2..84a861b8 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -2,12 +2,12 @@ class ScheduleController < ApplicationController layout "application" def index - @conference = Conference.includes(:rooms, {events: [:speakers, :track, :event_type]}).where("conferences.short_title" => params[:conference_id]).first + @conference = Conference.includes(:rooms, events: [:speakers, :track, :event_type]).where("conferences.short_title" => params[:conference_id]).first @rooms = @conference.rooms @events = @conference.events @dates = @conference.start_date..@conference.end_date - if @dates === Date.current + if @dates == Date.current @today = Date.current.strftime("%Y-%m-%d") else @today = @conference.start_date.strftime("%Y-%m-%d") diff --git a/app/models/event.rb b/app/models/event.rb index 70306615..08d5d1b4 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -195,7 +195,7 @@ class Event < ActiveRecord::Base begin if mail self.send(transition, - send_mail: send_mail_param) + send_mail: send_mail_param) else self.send(transition) end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index a71d3cdd..99546161 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -10,9 +10,9 @@ Devise.setup do |config| # Pass each provider to User model in :omniauth_providers (for open_id providers use their name) config.omniauth :open_id, name: 'novell', identifier: 'http://www.opensuse.org/openid/user' - config.omniauth :google_oauth2, Rails.application.secrets.google_key, Rails.application.secrets.google_secret, { - name: 'google', - scope: 'email' } + config.omniauth :google_oauth2, Rails.application.secrets.google_key, Rails.application.secrets.google_secret, + name: 'google', + scope: 'email' config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_secret # ==> Mailer Configuration diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 86523fc1..e3286fa0 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -19,15 +19,14 @@ describe Admin::ConferenceController do context 'valid attributes' do it 'locates the requested conference' do - patch :update, id: conference.short_title, conference: - attributes_for(:conference, title: 'Example Con') + patch :update, id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con') expect(assigns(:conference)).to eq(conference) end it 'changes conference attributes' do patch :update, id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con', - short_title: 'ExCon') + short_title: 'ExCon') conference.reload expect(conference.title).to eq('Example Con') @@ -67,7 +66,7 @@ describe Admin::ConferenceController do it 'does not change conference attributes' do patch :update, id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con', - short_title: nil) + short_title: nil) conference.reload expect(flash[:alert]). @@ -79,7 +78,7 @@ describe Admin::ConferenceController do it 're-renders the #show template' do patch :update, id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con', - short_title: nil) + short_title: nil) expect(flash[:alert]). to eq("Updating conference failed. Short title can't be blank.") @@ -266,8 +265,8 @@ describe Admin::ConferenceController do describe 'PATCH #update' do it 'requires admin privileges' do patch :update, id: conference.short_title, - conference: attributes_for(:conference, - short_title: 'ExCon') + conference: attributes_for(:conference, + short_title: 'ExCon') expect(response).to redirect_to(send(success_path)) end end diff --git a/spec/models/campaign_spec.rb b/spec/models/campaign_spec.rb index e836d3ba..0bf30aa5 100644 --- a/spec/models/campaign_spec.rb +++ b/spec/models/campaign_spec.rb @@ -15,7 +15,7 @@ describe Campaign do describe '#url_parameters' do it 'returns the parameters in the correct format' do campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement', - utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') + utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') campaign.conference = create(:conference) result = '?utm_source=google+&utm_medium=advertisement&utm_term=opensource&utm_content=content&utm_campaign=20percent' @@ -32,17 +32,17 @@ describe Campaign do describe '#visits' do it 'returns one if there is one visit' do campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement', - utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') + utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') campaign.conference = build(:conference) create(:visit, utm_source: 'google+', utm_medium: 'advertisement', - utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent', started_at: Time.now) + utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent', started_at: Time.now) expect(campaign.visits_count).to eq(1) end it 'returns zero if there are no visits' do campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement', - utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') + utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') campaign.conference = create(:conference) expect(campaign.visits_count).to eq(0) @@ -52,7 +52,7 @@ describe Campaign do describe '#registrations' do it 'returns zero if there are no registration' do campaign = build(:campaign, utm_source: 'google+', utm_medium: 'advertisement', - utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') + utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') campaign.conference = build(:conference) expect(campaign.registrations_count).to eq(0) @@ -62,7 +62,7 @@ describe Campaign do describe '#submissions' do it 'returns zero if there are no submissions' do campaign = build(:campaign, utm_source: 'google+', utm_medium: 'advertisement', - utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') + utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent') campaign.conference = build(:conference) expect(campaign.submissions_count).to eq(0)