Fix Rubocop offenses after Rubocop was reconfigured

This commit is contained in:
Felix Auringer
2021-05-25 12:45:38 +02:00
committed by Sebastian Serth
parent fc6aa12b0a
commit 63d997a7e3
6 changed files with 29 additions and 27 deletions

View File

@ -49,14 +49,15 @@ module SubmissionScoring
private :execute_test_file private :execute_test_file
def feedback_message(file, output) def feedback_message(_file, output)
# set_locale # TODO: why did we comment out set_locale and render_markdown?
set_locale
if output[:score] == Assessor::MAXIMUM_SCORE && output[:file_role] == 'teacher_defined_test' if output[:score] == Assessor::MAXIMUM_SCORE && output[:file_role] == 'teacher_defined_test'
I18n.t('exercises.implement.default_test_feedback') I18n.t('exercises.implement.default_test_feedback')
elsif output[:score] == Assessor::MAXIMUM_SCORE && output[:file_role] == 'teacher_defined_linter' elsif output[:score] == Assessor::MAXIMUM_SCORE && output[:file_role] == 'teacher_defined_linter'
I18n.t('exercises.implement.default_linter_feedback') I18n.t('exercises.implement.default_linter_feedback')
else else
# render_markdown(file.feedback_message) render_markdown(file.feedback_message)
end end
end end

View File

@ -9,7 +9,7 @@ class SubmissionsController < ApplicationController
include Tubesock::Hijack include Tubesock::Hijack
before_action :set_submission, before_action :set_submission,
only: %i[download download_file render_file run score extract_errors show statistics test] only: %i[download download_file render_file run score extract_errors show statistics]
before_action :set_files, only: %i[download download_file render_file show run] before_action :set_files, only: %i[download download_file render_file show run]
before_action :set_file, only: %i[download_file render_file run] before_action :set_file, only: %i[download_file render_file run]
before_action :set_mime_type, only: %i[download_file render_file] before_action :set_mime_type, only: %i[download_file render_file]
@ -134,7 +134,7 @@ class SubmissionsController < ApplicationController
def handle_websockets(tubesock, runner, socket) def handle_websockets(tubesock, runner, socket)
tubesock.send_data JSON.dump({'cmd' => 'status', 'status' => :container_running}) tubesock.send_data JSON.dump({'cmd' => 'status', 'status' => :container_running})
@output = String.new @output = +''
socket.on :output do |data| socket.on :output do |data|
Rails.logger.info("#{Time.zone.now.getutc}: Container sending: #{data}") Rails.logger.info("#{Time.zone.now.getutc}: Container sending: #{data}")
@ -239,9 +239,8 @@ class SubmissionsController < ApplicationController
def score def score
Thread.new do Thread.new do
hijack do |tubesock| hijack do |tubesock|
if @embed_options[:disable_run] return kill_socket(tubesock) if @embed_options[:disable_run]
return kill_socket(tubesock)
end
tubesock.send_data(@submission.calculate_score) tubesock.send_data(@submission.calculate_score)
# To enable hints when scoring a submission, uncomment the next line: # To enable hints when scoring a submission, uncomment the next line:
# send_hints(tubesock, StructuredError.where(submission: @submission)) # send_hints(tubesock, StructuredError.where(submission: @submission))

View File

@ -22,7 +22,7 @@ class Runner < ApplicationRecord
return runner if runner.save return runner if runner.save
raise(RunnerNotAvailableError, 'No runner available') raise RunnerNotAvailableError.new('No runner available')
end end
def copy_files(files) def copy_files(files)
@ -33,7 +33,7 @@ class Runner < ApplicationRecord
# runner has disappeared for some reason # runner has disappeared for some reason
destroy destroy
raise(RunnerNotAvailableError, 'Runner unavailable') raise RunnerNotAvailableError.new('Runner unavailable')
end end
def execute_command(command) def execute_command(command)
@ -42,7 +42,7 @@ class Runner < ApplicationRecord
if response.status == 404 if response.status == 404
# runner has disappeared for some reason # runner has disappeared for some reason
destroy destroy
raise(RunnerNotAvailableError, 'Runner unavailable') raise RunnerNotAvailableError.new('Runner unavailable')
end end
parse response parse response
end end

View File

@ -165,7 +165,7 @@ class Submission < ApplicationRecord
container_execution_time: execution_time, container_execution_time: execution_time,
status: exit_code.zero? ? :ok : :failed, status: exit_code.zero? ? :ok : :failed,
stdout: stdout, stdout: stdout,
stderr: stderr stderr: stderr,
} }
test_result(output, file) test_result(output, file)
end end
@ -210,7 +210,7 @@ class Submission < ApplicationRecord
{ {
class_name: File.basename(filename, File.extname(filename)).camelize, class_name: File.basename(filename, File.extname(filename)).camelize,
filename: filename, filename: filename,
module_name: File.basename(filename, File.extname(filename)).underscore module_name: File.basename(filename, File.extname(filename)).underscore,
} }
end end
end end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateRunners < ActiveRecord::Migration[6.1] class CreateRunners < ActiveRecord::Migration[6.1]
def change def change
create_table :runners do |t| create_table :runners do |t|