Skip to content

Commit 18a7bee

Browse files
committed
Code style for v8
1 parent edd229e commit 18a7bee

File tree

65 files changed

+171
-43
lines changed

Some content is hidden

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

65 files changed

+171
-43
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AllCops:
66
- 'db/**/*'
77
- 'ext/**/*'
88
- 'tmp/**/*'
9-
TargetRubyVersion: 2.2
9+
TargetRubyVersion: 2.5
1010

1111
Rails:
1212
Enabled: true

app/controllers/api/v8/apidocs_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Api
24
module V8
35
class ApidocsController < ActionController::Base
@@ -134,7 +136,7 @@ class ApidocsController < ActionController::Base
134136
end
135137
end
136138
key :host, 'localhost:3000'
137-
key :schemes, %w(http https)
139+
key :schemes, %w[http https]
138140
key :consumes, ['application/json']
139141
key :produces, ['application/json']
140142
end

app/controllers/api/v8/application/credentials_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Api
24
module V8
35
module Application

app/controllers/api/v8/base_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'json'
24

35
module Api
@@ -31,8 +33,8 @@ def present(hash)
3133
def authenticate_user!
3234
return @current_user if @current_user
3335
if doorkeeper_token
34-
@current_user ||= User.find_by_id(doorkeeper_token.resource_owner_id)
35-
fail 'Invalid token' unless @current_user
36+
@current_user ||= User.find_by(id: doorkeeper_token.resource_owner_id)
37+
raise 'Invalid token' unless @current_user
3638
end
3739
@current_user ||= user_from_session || Guest.new
3840
end

app/controllers/api/v8/core.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Api
24
module V8
35
module Core

app/controllers/api/v8/core/courses/reviews_controller.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Api
24
module V8
35
module Core
@@ -54,9 +56,9 @@ def index
5456
course = Course.find_by!(id: params[:course_id])
5557
authorize! :read, course
5658
users_reviewed_submissions = course.submissions
57-
.where(user_id: current_user.id)
58-
.where('requests_review OR requires_review OR reviewed')
59-
.order('created_at DESC')
59+
.where(user_id: current_user.id)
60+
.where('requests_review OR requires_review OR reviewed')
61+
.order('created_at DESC')
6062

6163
present Review.course_reviews_json(course, users_reviewed_submissions, view_context)
6264
end
@@ -81,7 +83,7 @@ def update_review
8183
award_points
8284
@review.submission.save!
8385
@review.save!
84-
rescue
86+
rescue StandardError
8587
::Rails.logger.error($!)
8688
respond_with_error('Failed to save code review.')
8789
else
@@ -119,16 +121,16 @@ def mark_as_reviewed
119121
sub.reviewed = true
120122
sub.review_dismissed = false
121123
sub.of_same_kind
122-
.where('(requires_review OR requests_review) AND NOT reviewed')
123-
.where(['created_at < ?', sub.created_at])
124-
.update_all(newer_submission_reviewed: true)
124+
.where('(requires_review OR requests_review) AND NOT reviewed')
125+
.where(['created_at < ?', sub.created_at])
126+
.update_all(newer_submission_reviewed: true)
125127
end
126128

127129
def award_points
128130
submission = @review.submission
129131
exercise = submission.exercise
130132
course = exercise.course
131-
fail 'Exercise of submission has been moved or deleted' unless exercise
133+
raise 'Exercise of submission has been moved or deleted' unless exercise
132134

133135
available_points = exercise.available_points.where(requires_review: true).map(&:name)
134136
previous_points = course.awarded_points.where(user_id: submission.user_id, name: available_points).map(&:name)
@@ -137,7 +139,7 @@ def award_points
137139
if params[:review][:points].respond_to?(:keys)
138140
params[:review][:points].keys.each do |point_name|
139141
unless exercise.available_points.where(name: point_name).any?
140-
fail "Point does not exist: #{point_name}"
142+
raise "Point does not exist: #{point_name}"
141143
end
142144

143145
new_points << point_name

app/controllers/api/v8/core/courses/unlocks_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Api
24
module V8
35
module Core

app/controllers/api/v8/core/courses_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Api
24
module V8
35
module Core

app/controllers/api/v8/core/exercises/solutions_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Api
24
module V8
35
module Core

app/controllers/api/v8/core/exercises/submissions_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Api
24
module V8
35
module Core
@@ -96,7 +98,7 @@ def create
9698

9799
unless @submission.save
98100
errormsg = 'Failed to save submission.'
99-
errormsg += " Errors: #{@submission.errors.messages.to_s}"
101+
errormsg += " Errors: #{@submission.errors.messages}"
100102
end
101103
end
102104

0 commit comments

Comments
 (0)