diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e25cb2ae..9c389afd 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
MEMBER_ACTIONS = %i[destroy edit show update].freeze
RENDER_HOST = CodeOcean::Config.new(:code_ocean).read[:render_host]
LEGAL_SETTINGS = CodeOcean::Config.new(:code_ocean).read[:legal] || {}
- MONITORING_USER_AGENT = Regexp.compile(/updown\.io/).freeze
+ MONITORING_USER_AGENT = /updown\.io/
before_action :deny_access_from_render_host
after_action :verify_authorized, except: %i[welcome]
diff --git a/app/services/proforma_service/import.rb b/app/services/proforma_service/import.rb
index c58eccab..b9598e26 100644
--- a/app/services/proforma_service/import.rb
+++ b/app/services/proforma_service/import.rb
@@ -67,7 +67,7 @@ module ProformaService
zip_file.map(&:name)
end
- filenames.select {|f| f[/\.xml$/] }.any?
+ filenames.any? {|f| f[/\.xml$/] }
rescue Zip::Error
raise Proforma::InvalidZip
end
diff --git a/db/migrate/20220415215112_migrate_testruns.rb b/db/migrate/20220415215112_migrate_testruns.rb
index fae26575..fa3435c7 100644
--- a/db/migrate/20220415215112_migrate_testruns.rb
+++ b/db/migrate/20220415215112_migrate_testruns.rb
@@ -4,17 +4,17 @@ class MigrateTestruns < ActiveRecord::Migration[6.1]
# We are not changing any tables but only backfilling data.
disable_ddl_transaction!
- SPLIT_OUTPUT = Regexp.compile(/(?message: (?.*)\n|status: (?.*)\n)? stdout: (?.*)\n stderr: ?(?.*)/m)
- PYTHON_BYTE_OUTPUT = Regexp.compile(/^b'(?.*)'$/)
- PYTHON_JSON_OUTPUT = Regexp.compile(/{"cmd":"write","stream":"(?.*)","data":"(?.*)"}/)
- RUN_OUTPUT = Regexp.compile(%r{(?timeout:)? ?(?>make run\r\n)?(?>python3 /usr/lib/[^\r\n]*\r\n|/usr/bin/python3[^\r\n]*\r\n|ruby [^\r\n]*\r\n)?(?[^ "\e][^\e]*?[^#\e])?(?\r\e.*?)?#?(?exit|timeout)?\r?\Z}m)
- REAL_EXIT = Regexp.compile(/\A(?>(?(?{".*?)?(?>{"cmd":(?> |"write","stream":"stdout","data":)?"#?exit(?>\\[nr])?"})+(?.*))|(?.*?)(?>#?exit\s*)+(?.*))\z/m)
- STDERR_WRITTEN = Regexp.compile(/^(?:(?\r*[^\n\r]*\.rb:\d+:.*)|(?\r*[^\n\r]*\.java:\d+: error.*|\r*Exception in thread.*|\r*There was .*|\r*[^\n\r]*java\.lang\..*|\r*make: \*\*\* \[.*))\z/m)
- FIND_JSON = Regexp.compile(/{(?:(?:"(?:\\.|[^\\"])+?"\s*:\s*(?:"(?:\\.|[^\\"])*?"|-?\d++(?:\.\d++)?|\[.*?\]|{.*?}|null))+?\s*,?\s*)+}/)
+ SPLIT_OUTPUT = /(?message: (?.*)\n|status: (?.*)\n)? stdout: (?.*)\n stderr: ?(?.*)/m
+ PYTHON_BYTE_OUTPUT = /^b'(?.*)'$/
+ PYTHON_JSON_OUTPUT = /{"cmd":"write","stream":"(?.*)","data":"(?.*)"}/
+ RUN_OUTPUT = %r{(?timeout:)? ?(?>make run\r\n)?(?>python3 /usr/lib/[^\r\n]*\r\n|/usr/bin/python3[^\r\n]*\r\n|ruby [^\r\n]*\r\n)?(?[^ "\e][^\e]*?[^#\e])?(?\r\e.*?)?#?(?exit|timeout)?\r?\Z}m
+ REAL_EXIT = /\A(?>(?(?{".*?)?(?>{"cmd":(?> |"write","stream":"stdout","data":)?"#?exit(?>\\[nr])?"})+(?.*))|(?.*?)(?>#?exit\s*)+(?.*))\z/m
+ STDERR_WRITTEN = /^(?:(?\r*[^\n\r]*\.rb:\d+:.*)|(?\r*[^\n\r]*\.java:\d+: error.*|\r*Exception in thread.*|\r*There was .*|\r*[^\n\r]*java\.lang\..*|\r*make: \*\*\* \[.*))\z/m
+ FIND_JSON = /{(?:(?:"(?:\\.|[^\\"])+?"\s*:\s*(?:"(?:\\.|[^\\"])*?"|-?\d++(?:\.\d++)?|\[.*?\]|{.*?}|null))+?\s*,?\s*)+}/
# We identify incomplete Unicode characters. Valid unicode characters are:
# \uXXXX, \u{XXXXX}, \udYXX\udZXX with X = 0-9a-f, Y = 89ab, Z = cdef
# Every incomplete prefix of a valid unicode character is identified
- REPLACE_INCOMPLETE_UNICODE = Regexp.compile(/(?:\\?\\u[\da-f]{0,3}|\\?\\ud[89ab][\da-f]{2}\\?(?:\\(?:u(?:d(?:[cdef][\da-f]?)?)?)?)?|\\?\\u\{[\da-f]{0,4})"}\z/)
+ REPLACE_INCOMPLETE_UNICODE = /(?:\\?\\u[\da-f]{0,3}|\\?\\ud[89ab][\da-f]{2}\\?(?:\\(?:u(?:d(?:[cdef][\da-f]?)?)?)?)?|\\?\\u\{[\da-f]{0,4})"}\z/
# NOTE: `update_columns` won't run validations nor update the `updated_at` timestamp.
# This is what we want here, thus we disable Rubocop for this migration.
diff --git a/lib/runner/connection/buffer.rb b/lib/runner/connection/buffer.rb
index 2a5dd838..03b358bd 100644
--- a/lib/runner/connection/buffer.rb
+++ b/lib/runner/connection/buffer.rb
@@ -6,7 +6,7 @@ class Runner::Connection::Buffer
# substring either in single or double quotes (e.g., within a JSON). Originally, each line break consists of `\r\n`.
# We keep the `\r` at the end of the line (keeping "empty" lines) and replace it after buffering.
# Inspired by https://stackoverflow.com/questions/13040585/split-string-by-spaces-properly-accounting-for-quotes-and-backslashes-ruby
- SPLIT_INDIVIDUAL_LINES = Regexp.compile(/(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^\n])+/)
+ SPLIT_INDIVIDUAL_LINES = /(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^\n])+/
def initialize
@global_buffer = +''
diff --git a/spec/factories/code_ocean/file.rb b/spec/factories/code_ocean/file.rb
index 6b173268..5d8606fb 100644
--- a/spec/factories/code_ocean/file.rb
+++ b/spec/factories/code_ocean/file.rb
@@ -6,15 +6,15 @@ module CodeOcean
FactoryBot.define do
factory :file, class: 'CodeOcean::File' do
content { '' }
- association :context, factory: :submission
- association :file_type, factory: :dot_rb
+ context factory: :submission
+ file_type factory: :dot_rb
hidden { false }
name { SecureRandom.hex }
read_only { false }
role { 'main_file' }
trait(:image) do
- association :file_type, factory: :dot_png
+ file_type factory: :dot_png
name { 'poster' }
native_file { Rack::Test::UploadedFile.new(Rails.root.join('db/seeds/audio_video/poster.png'), 'image/png') }
end
@@ -22,8 +22,8 @@ module CodeOcean
factory :test_file, class: 'CodeOcean::File' do
content { '' }
- association :context, factory: :dummy
- association :file_type, factory: :dot_rb
+ context factory: :dummy
+ file_type factory: :dot_rb
hidden { true }
name { SecureRandom.hex }
read_only { true }
diff --git a/spec/factories/codeharbor_link.rb b/spec/factories/codeharbor_link.rb
index 692a2aeb..e2238e0e 100644
--- a/spec/factories/codeharbor_link.rb
+++ b/spec/factories/codeharbor_link.rb
@@ -2,7 +2,7 @@
FactoryBot.define do
factory :codeharbor_link do
- user { build(:teacher) }
+ user factory: :teacher
push_url { 'https://push.url' }
check_uuid_url { 'https://check-uuid.url' }
sequence(:api_key) {|n| "api_key#{n}" }
diff --git a/spec/factories/error_templates.rb b/spec/factories/error_templates.rb
index a0556912..c0f2ecaa 100644
--- a/spec/factories/error_templates.rb
+++ b/spec/factories/error_templates.rb
@@ -2,7 +2,7 @@
FactoryBot.define do
factory :error_template do
- association :execution_environment, factory: :ruby
+ execution_environment factory: :ruby
name { 'MyString' }
signature { 'MyString' }
end
diff --git a/spec/factories/external_user.rb b/spec/factories/external_user.rb
index e6d5f0f2..3d4427f0 100644
--- a/spec/factories/external_user.rb
+++ b/spec/factories/external_user.rb
@@ -2,7 +2,7 @@
FactoryBot.define do
factory :external_user do
- association :consumer
+ consumer
generated_email
external_id { SecureRandom.uuid }
generated_user_name
diff --git a/spec/factories/internal_user.rb b/spec/factories/internal_user.rb
index b6166061..c52bf94e 100644
--- a/spec/factories/internal_user.rb
+++ b/spec/factories/internal_user.rb
@@ -3,7 +3,7 @@
FactoryBot.define do
factory :admin, class: 'InternalUser' do
activated_user
- association :consumer
+ consumer
email { 'admin@example.org' }
generated_user_name
password { 'admin' }
@@ -17,7 +17,7 @@ FactoryBot.define do
factory :teacher, class: 'InternalUser' do
activated_user
- association :consumer
+ consumer
generated_email
generated_user_name
password { 'teacher' }
@@ -31,7 +31,7 @@ FactoryBot.define do
factory :learner, class: 'InternalUser' do
activated_user
- association :consumer
+ consumer
generated_email
generated_user_name
password { 'learner' }
diff --git a/spec/factories/lti_parameter.rb b/spec/factories/lti_parameter.rb
index df23526c..0eda270f 100644
--- a/spec/factories/lti_parameter.rb
+++ b/spec/factories/lti_parameter.rb
@@ -8,9 +8,9 @@ FactoryBot.define do
}.freeze
factory :lti_parameter do
- association :consumer
- association :exercise, factory: :math
- association :external_user
+ consumer
+ exercise factory: :math
+ external_user
lti_parameters { lti_params }
diff --git a/spec/factories/request_for_comment.rb b/spec/factories/request_for_comment.rb
index e6b15067..b6dc4ed2 100644
--- a/spec/factories/request_for_comment.rb
+++ b/spec/factories/request_for_comment.rb
@@ -2,10 +2,10 @@
FactoryBot.define do
factory :rfc, class: 'RequestForComment' do
- association :user, factory: :external_user
- association :exercise, factory: :math
+ user factory: :external_user
+ exercise factory: :math
submission { association :submission, exercise:, user: }
- association :file
+ file
sequence :question do |n|
"test question #{n}"
end
diff --git a/spec/factories/runner.rb b/spec/factories/runner.rb
index 28c6ffd9..3ce0941f 100644
--- a/spec/factories/runner.rb
+++ b/spec/factories/runner.rb
@@ -4,7 +4,7 @@
FactoryBot.define do
factory :runner do
runner_id { SecureRandom.uuid }
- association :execution_environment, factory: :ruby
- association :user, factory: :external_user
+ execution_environment factory: :ruby
+ user factory: :external_user
end
end
diff --git a/spec/factories/shared_traits.rb b/spec/factories/shared_traits.rb
index 9bf58648..52bcbd5f 100644
--- a/spec/factories/shared_traits.rb
+++ b/spec/factories/shared_traits.rb
@@ -3,7 +3,7 @@
FactoryBot.define do
%i[admin external_user teacher].each do |factory_name|
trait :"created_by_#{factory_name}" do
- association :user, factory: factory_name
+ user factory: factory_name
end
end
diff --git a/spec/factories/structured_error_attributes.rb b/spec/factories/structured_error_attributes.rb
index 6349580d..00727896 100644
--- a/spec/factories/structured_error_attributes.rb
+++ b/spec/factories/structured_error_attributes.rb
@@ -2,8 +2,8 @@
FactoryBot.define do
factory :structured_error_attribute do
- association :structured_error
- association :error_template_attribute
+ structured_error
+ error_template_attribute
value { 'MyString' }
end
end
diff --git a/spec/factories/structured_errors.rb b/spec/factories/structured_errors.rb
index 921e8ff6..4d716ec4 100644
--- a/spec/factories/structured_errors.rb
+++ b/spec/factories/structured_errors.rb
@@ -2,7 +2,7 @@
FactoryBot.define do
factory :structured_error do
- association :error_template
- association :submission
+ error_template
+ submission
end
end
diff --git a/spec/factories/study_group.rb b/spec/factories/study_group.rb
index be4ad0ae..f933af04 100644
--- a/spec/factories/study_group.rb
+++ b/spec/factories/study_group.rb
@@ -2,7 +2,7 @@
FactoryBot.define do
factory :study_group, class: 'StudyGroup' do
- association :consumer
+ consumer
sequence :name do |n|
"TestGroup#{n}"
end
diff --git a/spec/factories/submission.rb b/spec/factories/submission.rb
index 39f9f338..28f841ed 100644
--- a/spec/factories/submission.rb
+++ b/spec/factories/submission.rb
@@ -4,7 +4,7 @@ FactoryBot.define do
factory :submission do
cause { 'save' }
created_by_external_user
- association :exercise, factory: :math
+ exercise factory: :math
after(:create) do |submission|
submission.exercise.files.editable.visible.each do |file|
diff --git a/spec/factories/user_exercise_feedback.rb b/spec/factories/user_exercise_feedback.rb
index 9c8de052..ecad57d2 100644
--- a/spec/factories/user_exercise_feedback.rb
+++ b/spec/factories/user_exercise_feedback.rb
@@ -4,6 +4,6 @@ FactoryBot.define do
factory :user_exercise_feedback, class: 'UserExerciseFeedback' do
created_by_external_user
feedback_text { 'Most suitable exercise ever' }
- association :exercise, factory: :math
+ exercise factory: :math
end
end
diff --git a/spec/policies/request_for_comment_policy_spec.rb b/spec/policies/request_for_comment_policy_spec.rb
index 8305a155..184cc4c3 100644
--- a/spec/policies/request_for_comment_policy_spec.rb
+++ b/spec/policies/request_for_comment_policy_spec.rb
@@ -184,7 +184,7 @@ describe RequestForCommentPolicy do
end
it 'does not grant access to authors of another primary study groups' do
- rfc_other_study_group.author.update(study_groups: [create(:study_group)])
+ rfc_other_study_group.author.update(study_groups: create_list(:study_group, 1))
expect(policy).not_to permit(rfc_other_study_group.author, rfc_other_study_group)
end