Skip to content

Commit 972ac06

Browse files
committed
Use Rubocop to do auto-correction.
1 parent 4cd98bb commit 972ac06

File tree

235 files changed

+8094
-9222
lines changed

Some content is hidden

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

235 files changed

+8094
-9222
lines changed

Capfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ require 'capistrano/deploy'
2424
require 'capistrano/rails'
2525

2626
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
27-
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
27+
Dir.glob('lib/capistrano/tasks/*.rake').each {|r| import r }

Gemfile

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ gem 'delayed_job_active_record'
1515
gem 'dynamic_form'
1616
gem 'edavis10-ruby-web-search'
1717
gem 'engtagger'
18-
gem 'expertiza-authlogic', github: 'expertiza/authlogic', :require => 'authlogic'
18+
gem 'expertiza-authlogic', github: 'expertiza/authlogic', require: 'authlogic'
1919
gem 'fastercsv'
2020
gem 'ffi-aspell'
2121
gem 'font-awesome-rails'
22-
gem 'gchartrb', :require => 'google_chart'
23-
gem "googlecharts", :require => "gchart"
24-
gem 'gdata', :require => false
22+
gem 'gchartrb', require: 'google_chart'
23+
gem "googlecharts", require: "gchart"
24+
gem 'gdata', require: false
2525
gem 'graphviz'
2626
gem 'haml-rails'
2727
gem 'hoptoad_notifier'
@@ -42,10 +42,10 @@ gem 'rake'
4242
gem 'rb-readline'
4343
gem 'rest-client', '~> 1.8'
4444
gem 'RedCloth'
45-
gem 'rgl', :require => 'rgl/adjacency'
45+
gem 'rgl', require: 'rgl/adjacency'
4646
gem 'rjb'
4747
gem 'rubyzip'
48-
gem 'rwordnet','0.1.3'
48+
gem 'rwordnet', '0.1.3'
4949
gem 'scrypt'
5050
gem 'sass-rails', '5.0.3'
5151
gem 'seer'
@@ -89,5 +89,5 @@ end
8989

9090
group :development, :test do
9191
gem 'capybara'
92-
gem 'simplecov', :require => false
93-
end
92+
gem 'simplecov', require: false
93+
end

Guardfile

+6-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ guard 'rails' do
66
watch(%r{^(config|lib)/.*})
77
end
88

9-
109
# Note: The cmd option is now required due to the increasing number of ways
1110
# rspec may be run, below are examples of the most common uses.
1211
# * bundler: 'bundle exec rspec'
@@ -17,23 +16,22 @@ end
1716
# * 'just' rspec: 'rspec'
1817
guard :rspec, cmd: 'bundle exec rspec' do
1918
watch(%r{^spec/.+_spec\.rb$})
20-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
19+
watch(%r{^lib/(.+)\.rb$}) {|m| "spec/lib/#{m[1]}_spec.rb" }
2120
watch('spec/spec_helper.rb') { "spec" }
2221

2322
# Rails example
24-
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
25-
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
26-
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
23+
watch(%r{^app/(.+)\.rb$}) {|m| "spec/#{m[1]}_spec.rb" }
24+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) {|m| "spec/#{m[1]}#{m[2]}_spec.rb" }
25+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) {|m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
2726
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
2827
watch('config/routes.rb') { "spec/routing" }
2928
watch('app/controllers/application_controller.rb') { "spec/controllers" }
3029
watch('spec/rails_helper.rb') { "spec" }
3130

3231
# Capybara features specs
33-
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
32+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) {|m| "spec/features/#{m[1]}_spec.rb" }
3433

3534
# Turnip features and steps
3635
watch(%r{^spec/acceptance/(.+)\.feature$})
37-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
36+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) {|m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
3837
end
39-

app/controllers/admin_controller.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def action_allowed?
99
end
1010

1111
def list_instructors
12-
@users = User.instructors.order(:name).where("parent_id = ?", current_user.id).paginate(:page => params[:page], :per_page => 50)
12+
@users = User.instructors.order(:name).where("parent_id = ?", current_user.id).paginate(page: params[:page], per_page: 50)
1313
end
1414

1515
def add_administrator
@@ -27,11 +27,11 @@ def create_administrator
2727
end
2828

2929
def list_administrators
30-
@users = User.admins.order(:name).where("parent_id = ?", current_user.id).paginate(:page => params[:page], :per_page => 50)
30+
@users = User.admins.order(:name).where("parent_id = ?", current_user.id).paginate(page: params[:page], per_page: 50)
3131
end
3232

3333
def list_users(conditions)
34-
@users = User.order(:name).where(conditions).paginate(:page => params[:page], :per_page => 50)
34+
@users = User.order(:name).where(conditions).paginate(page: params[:page], per_page: 50)
3535
end
3636

3737
def new_super_administrator
@@ -46,7 +46,7 @@ def show_instructor
4646
@user = User.find(params[:id])
4747
@role = Role.find(@user.role_id)
4848
end
49-
49+
5050
def show_super_admin
5151
@user = User.find(params[:id])
5252
@role = Role.find(@user.role_id)
@@ -59,14 +59,14 @@ def show_admin
5959

6060
def remove_instructor
6161
User.find(params[:id]).destroy
62-
redirect_to :action => 'list_instructors'
62+
redirect_to action: 'list_instructors'
6363
end
6464

6565
def remove_administrator
6666
User.find(params[:id]).destroy
67-
redirect_to :action => 'list_administrators'
67+
redirect_to action: 'list_administrators'
6868
end
69-
69+
7070
def save_super_administrator
7171
PgUsersController.create(Role.superadministrator.id, :admin_controller, :list_super_administrators, :new_super_administrator)
7272
end

app/controllers/advertise_for_partner_controller.rb

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,51 @@ def action_allowed?
33
current_user.role.name.eql?("Student")
44
end
55

6-
#adds a new advertise for partners entry in team table...
6+
# adds a new advertise for partners entry in team table...
77
def new
88
end
99

10-
#removes an entry from team table for corresponding team who requested to remove their advertisement for partner request
10+
# removes an entry from team table for corresponding team who requested to remove their advertisement for partner request
1111
def remove
1212
team = Team.find(params[:team_id])
1313
team.advertise_for_partner = false
1414
team.comments_for_advertisement = nil
1515
team.save
1616

17-
assignment=Assignment.find(Team.find(params[:team_id]).parent_id)
18-
participant=AssignmentParticipant.where(parent_id: assignment.id, user_id: session[:user].id).first
17+
assignment = Assignment.find(Team.find(params[:team_id]).parent_id)
18+
participant = AssignmentParticipant.where(parent_id: assignment.id, user_id: session[:user].id).first
1919
redirect_to view_student_teams_path student_id: participant.id
2020
end
2121

22-
#update the team table with newly created advertise for partner request for the corresponding team
22+
# update the team table with newly created advertise for partner request for the corresponding team
2323
def create
2424
team = Team.find(params[:id])
2525
team.advertise_for_partner = true
2626
team.comments_for_advertisement = params[:comments_for_advertisement]
2727
team.save
2828

29-
assignment=Assignment.find(Team.find(params[:id]).parent_id)
30-
participant=AssignmentParticipant.where(parent_id: assignment.id, user_id: session[:user].id).first
29+
assignment = Assignment.find(Team.find(params[:id]).parent_id)
30+
participant = AssignmentParticipant.where(parent_id: assignment.id, user_id: session[:user].id).first
3131
redirect_to view_student_teams_path student_id: participant.id
3232
end
3333

34-
#update the advertisement when done with editing #####This should be edit rather than update....
34+
# update the advertisement when done with editing #####This should be edit rather than update....
3535
def update
36-
@team=Team.find(params[:id])
37-
#@team.comments_for_advertisement = params[:comments_for_advertisement]
38-
Team.update(params[:id], :comments_for_advertisement => params[:comments_for_advertisement])
39-
assignment=Assignment.find(Team.find(params[:id]).parent_id)
40-
participant=AssignmentParticipant.where(parent_id: assignment.id, user_id: session[:user].id).first
36+
@team = Team.find(params[:id])
37+
# @team.comments_for_advertisement = params[:comments_for_advertisement]
38+
Team.update(params[:id], comments_for_advertisement: params[:comments_for_advertisement])
39+
assignment = Assignment.find(Team.find(params[:id]).parent_id)
40+
participant = AssignmentParticipant.where(parent_id: assignment.id, user_id: session[:user].id).first
4141
if @team.save
42-
flash[:notice]='Your advertisement was successfully updated!'
42+
flash[:notice] = 'Your advertisement was successfully updated!'
4343
redirect_to view_student_teams_path student_id: participant.id
4444
else
45-
flash[:error]='An error occured and your advertisement was not updated!'
45+
flash[:error] = 'An error occured and your advertisement was not updated!'
4646
redirect_to view_student_teams_path student_id: participant.id
4747
end
4848
end
4949

50-
#find the team who wants to edit their advertisement
50+
# find the team who wants to edit their advertisement
5151
def edit
5252
@team = Team.find(params[:team_id])
5353
end

app/controllers/advice_controller.rb

+12-13
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@ def action_allowed?
77

88
# Modify the advice associated with a questionnaire
99
def edit_advice
10-
1110
@questionnaire = Questionnaire.find(params[:id])
1211

1312
for question in @questionnaire.questions
14-
if question.is_a?(ScoredQuestion)
15-
num_questions = @questionnaire.max_question_score - @questionnaire.min_question_score
16-
else
17-
num_questions=0
18-
end
13+
num_questions = if question.is_a?(ScoredQuestion)
14+
@questionnaire.max_question_score - @questionnaire.min_question_score
15+
else
16+
0
17+
end
1918

20-
sorted_advice = question.question_advices.sort_by { |x| -x.score }
19+
sorted_advice = question.question_advices.sort_by {|x| -x.score }
2120
if question.question_advices.length != num_questions or
2221
sorted_advice.empty? or
2322
sorted_advice[0].score != @questionnaire.min_question_score or
24-
sorted_advice[sorted_advice.length-1] != @questionnaire.max_question_score
23+
sorted_advice[sorted_advice.length - 1] != @questionnaire.max_question_score
2524
# The number of advices for this question has changed.
26-
QuestionnaireHelper::adjust_advice_size(@questionnaire, question)
25+
QuestionnaireHelper.adjust_advice_size(@questionnaire, question)
2726
end
2827
end
2928
end
@@ -33,15 +32,15 @@ def save_advice
3332
@questionnaire = Questionnaire.find(params[:id])
3433

3534
begin
36-
if !params[:advice].nil?
35+
unless params[:advice].nil?
3736
for advice_key in params[:advice].keys
38-
QuestionAdvice.update(advice_key, :advice=>params[:advice][advice_key.to_sym][:advice])
37+
QuestionAdvice.update(advice_key, advice: params[:advice][advice_key.to_sym][:advice])
3938
end
4039
flash[:notice] = "The questionnaire's question advice was successfully saved!"
4140
end
4241
rescue ActiveRecord::RecordNotFound
43-
render :action => 'edit_advice', :id => params[:id]
42+
render action: 'edit_advice', id: params[:id]
4443
end
45-
redirect_to :action => 'edit_advice', :id => params[:id]
44+
redirect_to action: 'edit_advice', id: params[:id]
4645
end
4746
end

0 commit comments

Comments
 (0)