Skip to content

Commit 2dfb598

Browse files
committed
Normalize Ruby syntax with Rubocop
1 parent d53f518 commit 2dfb598

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+567
-614
lines changed

Diff for: Gemfile

+25-23
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
source 'https://rubygems.org'
22

3-
gem 'rails', '5.1.6'
3+
gem 'rails', '5.1.6'
4+
45
gem 'pg'
56

6-
gem 'puma', '~> 3.11.4'
7+
gem 'puma', '~> 3.11.4'
78

8-
gem 'settingslogic'
9+
gem 'dotenv-rails'
910
gem 'newrelic_rpm'
11+
gem 'settingslogic'
12+
1013
gem 'devise', '~> 4.4.3'
1114
gem 'omniauth', '~> 1.6.1'
1215
gem 'omniauth-github'
1316
gem 'omniauth-twitter'
1417
gem 'simple_form', '~> 3.5.1'
15-
gem 'dotenv-rails'
1618

17-
gem 'modernizr-rails'
18-
gem 'sprockets-rails', '~> 3.2.0'
19-
gem 'jquery-rails'
20-
gem 'turbolinks'
21-
gem 'jbuilder', '~> 2.5'
19+
gem 'autoprefixer-rails', '~> 8.2'
2220
gem 'bourbon', '~> 5.0.0'
23-
gem 'neat', '~> 2.1.0'
21+
gem 'coffee-rails', '~> 4.2.1'
22+
gem 'draper', '~> 3.0.0.pre1'
2423
gem 'haml-rails', '~> 1.0.0'
25-
gem 'rails_html_helpers'
26-
gem 'draper', '~> 3.0.0.pre1'
24+
gem 'jbuilder', '~> 2.5'
25+
gem 'jquery-rails'
26+
gem 'modernizr-rails'
27+
gem 'neat', '~> 2.1.0'
2728
gem 'pundit'
29+
gem 'rails_html_helpers'
2830
gem 'redcarpet'
29-
gem 'sass-rails', '~> 5.0.6'
30-
gem 'coffee-rails', '~> 4.2.1'
31-
gem 'uglifier', '>= 1.0.3'
32-
33-
gem 'autoprefixer-rails', '~> 8.2'
31+
gem 'sass-rails', '~> 5.0.6'
32+
gem 'sprockets-rails', '~> 3.2.0'
33+
gem 'turbolinks'
34+
gem 'uglifier', '>= 1.0.3'
3435

3536
gem 'activemodel-serializers-xml'
3637

3738
group :development do
3839
gem 'foreman'
40+
3941
gem 'better_errors'
4042
gem 'binding_of_caller'
4143

@@ -45,18 +47,18 @@ group :development do
4547
end
4648

4749
group :test, :development do
48-
gem 'rspec-rails', '~> 3.3'
4950
gem 'factory_bot_rails', '~> 4.8'
51+
gem 'rspec-rails', '~> 3.3'
5052
end
5153

5254
group :test do
53-
gem 'rails-controller-testing'
54-
gem 'rspec-its'
55-
gem 'rspec-activemodel-mocks'
56-
gem 'simplecov', require: false
57-
gem 'capybara', '~> 2.1'
5855
gem 'accept_values_for'
56+
gem 'capybara', '~> 2.1'
5957
gem 'json_spec'
58+
gem 'rails-controller-testing'
59+
gem 'rspec-activemodel-mocks'
60+
gem 'rspec-its'
61+
gem 'simplecov', require: false
6062
end
6163

6264
group :production, :staging do

Diff for: Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Add your own tasks in files placed in lib/tasks ending in .rake,
22
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
33

4-
require File.expand_path('../config/application', __FILE__)
4+
require File.expand_path('config/application', __dir__)
55

66
Activities::Application.load_tasks

Diff for: app/controllers/activities_controller.rb

+26-27
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class ActivitiesController < ApiController
22
respond_to :html
33

4-
skip_before_action :authenticate_user!, only: [:index, :show]
4+
skip_before_action :authenticate_user!, only: %i[index show]
55
before_action :load_and_authorize_activity, only: %i[show edit update destroy]
66

77
def index
@@ -34,46 +34,45 @@ def create
3434

3535
def update
3636
if @activity
37-
type = @activity.update_attributes(sanitized_params) ? :notice : :error
37+
type = @activity.update(sanitized_params) ? :notice : :error
3838
flash[type] = I18n.t("edit_activity.#{type}")
3939
end
4040
respond_with(@activity, location: edit_activity_path(@activity))
4141
end
4242

4343
def destroy
4444
if @activity && params[:confirm_delete] && @activity.destroy
45-
redirect_to root_path, notice: I18n.t("destroy_activity.notice")
45+
redirect_to root_path, notice: I18n.t('destroy_activity.notice')
4646
else
47-
flash[:error] = I18n.t("destroy_activity.error")
47+
flash[:error] = I18n.t('destroy_activity.error')
4848
render :edit
4949
end
5050
end
5151

5252
private
5353

54-
def load_and_authorize_activity
55-
@activity = current_event.activity(params[:id]) or
56-
raise(ActiveRecord::RecordNotFound)
57-
authorize @activity
58-
@activity = @activity.decorate
59-
end
60-
61-
def sanitized_params
62-
params.require(:activity)
63-
.permit(:start_time,
64-
:end_time,
65-
:name,
66-
:location,
67-
:requirements,
68-
:requires_event_ticket,
69-
:description,
70-
:limit_of_participants,
71-
:anytime,
72-
:image_url)
73-
end
54+
def load_and_authorize_activity
55+
@activity = current_event.activity(params[:id]) or
56+
raise(ActiveRecord::RecordNotFound)
57+
authorize @activity
58+
@activity = @activity.decorate
59+
end
7460

75-
def query_params
76-
params.permit(:search, :filter)
77-
end
61+
def sanitized_params
62+
params.require(:activity)
63+
.permit(:start_time,
64+
:end_time,
65+
:name,
66+
:location,
67+
:requirements,
68+
:requires_event_ticket,
69+
:description,
70+
:limit_of_participants,
71+
:anytime,
72+
:image_url)
73+
end
7874

75+
def query_params
76+
params.permit(:search, :filter)
77+
end
7978
end

Diff for: app/controllers/api_controller.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
require_dependency 'api_responder'
22

33
class ApiController < ApplicationController
4-
54
self.responder = ApiResponder
6-
75
end

Diff for: app/controllers/application_controller.rb

+14-15
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,27 @@ def current_event
1919

2020
def not_found
2121
if request.xhr?
22-
render nothing: true, status: 404
22+
render nothing: true, status: :not_found
2323
else
24-
raise ActionController::RoutingError.new('Not Found')
24+
raise ActionController::RoutingError, 'Not Found'
2525
end
2626
end
2727

2828
private
2929

30-
def clean_up_session
31-
session[:omniauth] = nil
32-
end
33-
34-
def rescue_access_denied
35-
render nothing: true, status: 401
36-
end
30+
def clean_up_session
31+
session[:omniauth] = nil
32+
end
3733

38-
def rescue_record_not_found
39-
not_found
40-
end
34+
def rescue_access_denied
35+
render nothing: true, status: :unauthorized
36+
end
4137

42-
def layout_by_resource
43-
devise_controller? ? 'user' : 'application'
44-
end
38+
def rescue_record_not_found
39+
not_found
40+
end
4541

42+
def layout_by_resource
43+
devise_controller? ? 'user' : 'application'
44+
end
4645
end

Diff for: app/controllers/participations_controller.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ def destroy
2121

2222
private
2323

24-
def current_activity
25-
@current_activity ||= current_event.activity(params[:activity_id]).try(:decorate)
26-
end
27-
24+
def current_activity
25+
@current_activity ||= current_event.activity(params[:activity_id]).try(:decorate)
26+
end
2827
end

Diff for: app/controllers/registrations_controller.rb

+19-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class RegistrationsController < Devise::RegistrationsController
22
skip_before_action :authenticate_user!, only: :create
3-
skip_before_action :clean_up_session, only: [:new, :create]
3+
skip_before_action :clean_up_session, only: %i[new create]
44

55
helper_method :during_oauth_flow?
66

@@ -29,29 +29,28 @@ def update
2929

3030
private
3131

32-
def during_oauth_flow?
33-
!current_user && @user.new_record? && session[:omniauth].present?
34-
end
32+
def during_oauth_flow?
33+
!current_user && @user.new_record? && session[:omniauth].present?
34+
end
3535

36-
def build_resource(*args)
37-
super.tap do |user|
38-
if user && session[:omniauth]
39-
user.apply_omniauth(session[:omniauth])
40-
user.valid?
41-
end
36+
def build_resource(*args)
37+
super.tap do |user|
38+
if user && session[:omniauth]
39+
user.apply_omniauth(session[:omniauth])
40+
user.valid?
4241
end
4342
end
43+
end
4444

45-
def after_update_path_for(resource)
46-
edit_user_registration_path
47-
end
48-
49-
def sign_up_params
50-
editable_params
51-
end
45+
def after_update_path_for(_resource)
46+
edit_user_registration_path
47+
end
5248

53-
def editable_params
54-
params.require(:user).permit(:name, :email, :password, :password_confirmation, :show_participation)
55-
end
49+
def sign_up_params
50+
editable_params
51+
end
5652

53+
def editable_params
54+
params.require(:user).permit(:name, :email, :password, :password_confirmation, :show_participation)
55+
end
5756
end

0 commit comments

Comments
 (0)