Apply manual rubocop fixes

This commit is contained in:
Sebastian Serth
2021-05-14 11:07:11 +02:00
parent 6cbecb5b39
commit da0a682ffb
109 changed files with 431 additions and 416 deletions

View File

@ -6,7 +6,7 @@ class AddPoolSizeToExecutionEnvironments < ActiveRecord::Migration[4.2]
reversible do |direction|
direction.up do
ExecutionEnvironment.update_all(pool_size: 0)
ExecutionEnvironment.update(pool_size: 0)
end
end
end

View File

@ -6,7 +6,7 @@ class AddMemoryLimitToExecutionEnvironments < ActiveRecord::Migration[4.2]
reversible do |direction|
direction.up do
ExecutionEnvironment.update_all(memory_limit: DockerClient::DEFAULT_MEMORY_LIMIT)
ExecutionEnvironment.update(memory_limit: DockerClient::DEFAULT_MEMORY_LIMIT)
end
end
end

View File

@ -6,7 +6,7 @@ class AddNetworkEnabledToExecutionEnvironments < ActiveRecord::Migration[4.2]
reversible do |direction|
direction.up do
ExecutionEnvironment.update_all(network_enabled: true)
ExecutionEnvironment.update(network_enabled: true)
end
end
end

View File

@ -17,6 +17,6 @@ class CreateInterventions < ActiveRecord::Migration[4.2]
t.timestamps
end
Intervention.createDefaultInterventions
Intervention.create_default_interventions
end
end

View File

@ -3,6 +3,6 @@
class SetDefaultForRequestForCommentSolved < ActiveRecord::Migration[4.2]
def change
change_column_default :request_for_comments, :solved, false
RequestForComment.where(solved: nil).update_all(solved: false)
RequestForComment.where(solved: nil).update(solved: false)
end
end

View File

@ -6,7 +6,7 @@ class AddCauseToTestruns < ActiveRecord::Migration[4.2]
Testrun.reset_column_information
Testrun.all.each do |testrun|
if testrun.submission.nil?
say_with_time "#{testrun.id} has no submission" do end
say_with_time "#{testrun.id} has no submission"
else
testrun.cause = testrun.submission.cause
testrun.save

View File

@ -4,7 +4,7 @@ class AddReachedFullScoreToRequestForComment < ActiveRecord::Migration[4.2]
def up
add_column :request_for_comments, :full_score_reached, :boolean, default: false
RequestForComment.find_each do |rfc|
if rfc.submission.present? && rfc.submission.exercise.has_user_solved(rfc.user)
if rfc.submission.present? && rfc.submission.exercise.solved_by?(rfc.user)
rfc.full_score_reached = true
rfc.save
end

View File

@ -6,6 +6,6 @@ class AddUserToProxyExercise < ActiveRecord::Migration[5.2]
add_column :proxy_exercises, :public, :boolean, null: false, default: false
internal_user = InternalUser.find_by(id: 46) || InternalUser.first
ProxyExercise.update_all(user_id: internal_user&.id || 1, user_type: internal_user.class.name)
ProxyExercise.update(user_id: internal_user&.id || 1, user_type: internal_user.class.name)
end
end

View File

@ -5,6 +5,6 @@ class AddUserTypeToRemoteEvaluationMappings < ActiveRecord::Migration[5.2]
add_column :remote_evaluation_mappings, :user_type, :string
# Update all existing records and set user_type to `ExternalUser` (safe way to prevent any function loss).
# We are not using a default value here on intend to be in line with the other `user_type` columns
RemoteEvaluationMapping.update_all(user_type: 'ExternalUser')
RemoteEvaluationMapping.update(user_type: 'ExternalUser')
end
end

View File

@ -21,7 +21,7 @@ class DropErrors < ActiveRecord::Migration[5.2]
end
def change
puts 'Migrating CodeOcean::Errors to StructuredErrors using RegEx. This might take a (long) while but will return.'
Rails.logger.info 'Migrating CodeOcean::Errors to StructuredErrors using RegEx. This might take a (long) while but will return.'
submissions_controller = SubmissionsController.new
# Iterate only over those Errors containing a message and submission_id

View File

@ -6,8 +6,8 @@ class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
if table_exists?(:active_storage_blobs) && !column_exists?(:active_storage_blobs, :service_name)
add_column :active_storage_blobs, :service_name, :string
if configured_service = ActiveStorage::Blob.service.name
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
if (configured_service = ActiveStorage::Blob.service.name)
ActiveStorage::Blob.unscoped.update(service_name: configured_service)
end
change_column :active_storage_blobs, :service_name, :string, null: false

View File

@ -23,7 +23,7 @@ Rails.application.eager_load!
(ApplicationRecord.descendants - [ActiveRecord::SchemaMigration, User]).each(&:delete_all)
# delete file uploads
FileUtils.rm_rf(Rails.root.join('public', 'uploads'))
FileUtils.rm_rf(Rails.root.join('public/uploads'))
# load environment-dependent seeds
load(Rails.root.join('db', 'seeds', "#{Rails.env}.rb"))
load(Rails.root.join("db/seeds/#{Rails.env}.rb"))

View File

@ -1,3 +1,3 @@
# frozen_string_literal: true
def fibonacci(n); end
def fibonacci(number); end

View File

@ -4,11 +4,11 @@ require './exercise'
require './reference'
describe '#fibonacci' do
SAMPLE_COUNT = 32
let(:sample_count) { 32 }
let(:reference) { Class.new.extend(Reference) }
SAMPLE_COUNT.times do |i|
sample_count.times do |i|
instance_eval do
it "obtains the correct result for input #{i}" do
expect(fibonacci(i)).to eq(reference.fibonacci(i))

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
module Reference
def fibonacci(n)
n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2)
def fibonacci(number)
number < 2 ? number : fibonacci(number - 1) + fibonacci(number - 2)
end
end

View File

@ -0,0 +1,3 @@
# frozen_string_literal: true
# Write your code here

View File

@ -29,7 +29,7 @@ FileType.create_factories
# change all resources' author
[ExecutionEnvironment, Exercise, FileType].each do |model|
model.update_all(user_id: InternalUser.first.id)
model.update(user_id: InternalUser.first.id)
end
# delete temporary users

View File

@ -10,5 +10,7 @@ database = SQLite3::Database.new('/database.db')
missing_tuples = database.execute(REFERENCE_QUERY) - database.execute(STUDENT_QUERY)
unexpected_tuples = database.execute(STUDENT_QUERY) - database.execute(REFERENCE_QUERY)
# rubocop:disable Rails/Output
puts("Missing tuples: #{missing_tuples}")
puts("Unexpected tuples: #{unexpected_tuples}")
# rubocop:enable Rails/Output

View File

@ -0,0 +1,3 @@
# frozen_string_literal: true
# Write your code here