From fc5bce43b3bea95ea0a2acf697954f2cdb2f145f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 04:12:19 +0000 Subject: [PATCH 1/2] Bump rubocop from 1.76.2 to 1.77.0 Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.76.2 to 1.77.0. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.76.2...v1.77.0) --- updated-dependencies: - dependency-name: rubocop dependency-version: 1.77.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f62e1064a..ea0acb74f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -472,7 +472,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.4) - rubocop (1.76.2) + rubocop (1.77.0) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -942,7 +942,7 @@ CHECKSUMS rspec-mocks (3.13.5) sha256=e4338a6f285ada9fe56f5893f5457783af8194f5d08884d17a87321d5195ea81 rspec-rails (8.0.1) sha256=0c3700b10ab6d7c648c4cd554023d8c2b5b07e7f01205f7608f0c511cf686505 rspec-support (3.13.4) sha256=184b1814f6a968102b57df631892c7f1990a91c9a3b9e80ef892a0fc2a71a3f7 - rubocop (1.76.2) sha256=ae44f172ba0bbe3d623c927111798f85a7879bcc88e544d08f51f62c19f45633 + rubocop (1.77.0) sha256=1f360b4575ef7a124be27b0dfffa227a2b2d9420d22d4fd8bf179d702bcc88c0 rubocop-ast (1.45.1) sha256=94042e49adc17f187ba037b33f941ba7398fede77cdf4bffafba95190a473a3e rubocop-capybara (2.22.1) sha256=ced88caef23efea53f46e098ff352f8fc1068c649606ca75cb74650970f51c0c rubocop-factory_bot (2.27.1) sha256=9d744b5916778c1848e5fe6777cc69855bd96548853554ec239ba9961b8573fe From cbf3a08eb7e9bd708332d83d12a3e5228b364577 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Tue, 24 Jun 2025 16:55:35 +0200 Subject: [PATCH 2/2] Fix Rubocop offenses --- app/controllers/community_solutions_controller.rb | 4 ++-- app/controllers/exercises_controller.rb | 2 +- app/controllers/submissions_controller.rb | 2 +- app/models/code_ocean/file.rb | 2 +- app/models/exercise.rb | 4 ++-- app/models/testrun_message.rb | 2 +- app/views/shared/_form_errors.html.slim | 2 +- app/views/submissions/show.json.jbuilder | 2 +- lib/java21_study.rb | 8 ++++---- spec/system/editor_system_spec.rb | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/community_solutions_controller.rb b/app/controllers/community_solutions_controller.rb index 2c37d559c..cc60f584f 100644 --- a/app/controllers/community_solutions_controller.rb +++ b/app/controllers/community_solutions_controller.rb @@ -32,14 +32,14 @@ def edit # If the first user did not save, the ReadMe file already exists @files << CodeOcean::File.find_or_create_by!(new_readme_file) end - all_visible_files = last_contribution.files.select(&:visible) + all_visible_files = last_contribution.files.select(&:visible?) # Add the ReadMe file first @files += all_visible_files.select {|f| CodeOcean::File.find_by(id: f.file_id)&.context_type == 'CommunitySolution' } # Then, add all remaining files and sort them by name with extension @files += (all_visible_files - @files).sort_by(&:filepath) # Own Submission as a reference - @own_files = @submission.collect_files.select(&:visible).sort_by(&:filepath) + @own_files = @submission.collect_files.select(&:visible?).sort_by(&:filepath) # Remove the file_id from the second graph. Otherwise, the comparison and file-tree selection does not work as expected @own_files.map do |file| file.file_id = nil diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index b8ab2dbfc..c9ac076f9 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -418,7 +418,7 @@ def implement # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedC @hide_rfc_button = @embed_options[:disable_rfc] @submission = current_contributor.submissions.order(created_at: :desc).find_by(exercise: @exercise) - @files = (@submission ? @submission.collect_files : @exercise.files).select(&:visible).sort_by(&:filepath) + @files = (@submission ? @submission.collect_files : @exercise.files).select(&:visible?).sort_by(&:filepath) @paths = collect_paths(@files) end diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 18d70b4bc..a19787dec 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -469,7 +469,7 @@ def set_files_and_specific_file end def set_files - @files = @submission.collect_files.select(&:visible) + @files = @submission.collect_files.select(&:visible?) end def set_submission diff --git a/app/models/code_ocean/file.rb b/app/models/code_ocean/file.rb index 86ccccca8..0d9327531 100644 --- a/app/models/code_ocean/file.rb +++ b/app/models/code_ocean/file.rb @@ -153,7 +153,7 @@ def set_default_values end private :set_default_values - def visible + def visible? !hidden end diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 838122a8f..601bb9e2f 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -377,7 +377,7 @@ def get_quantiles(quantiles) SELECT unnest(percentile_cont(#{self.class.sanitize_sql(['array[?]', quantiles])}) within GROUP (ORDER BY working_time)) FROM result ") - if result.count.positive? + if result.any? quantiles.each_with_index.map {|_q, i| parse_duration(result[i]['unnest']).to_f } else quantiles.map {|_q| 0 } @@ -512,7 +512,7 @@ def set_default_values private :set_default_values def valid_main_file? - if files.count(&:main_file?) > 1 + if files.many?(&:main_file?) errors.add(:files, :at_most_one_main_file) end end diff --git a/app/models/testrun_message.rb b/app/models/testrun_message.rb index 597c5dc36..daab5e5cf 100644 --- a/app/models/testrun_message.rb +++ b/app/models/testrun_message.rb @@ -99,7 +99,7 @@ def self.validate_and_store!(messages) private_class_method :validate_and_store! def either_data_or_log - if [data, log].count(&:present?) > 1 + if [data, log].many?(&:present?) errors.add(log, "can't be present if data is also present") end end diff --git a/app/views/shared/_form_errors.html.slim b/app/views/shared/_form_errors.html.slim index ce2001a14..89eb74ad9 100644 --- a/app/views/shared/_form_errors.html.slim +++ b/app/views/shared/_form_errors.html.slim @@ -1,6 +1,6 @@ - if object.errors.any? #error_explanation.alert.alert-warning - h4 = "#{t("shared.errors_#{object.errors.count == 1 ? 'one' : 'other'}", count: object.errors.count, model: object.class.model_name.human)}:" + h4 = "#{t("shared.errors_#{object.errors.one? ? 'one' : 'other'}", count: object.errors.count, model: object.class.model_name.human)}:" ul - object.errors.full_messages.each do |message| li = message diff --git a/app/views/submissions/show.json.jbuilder b/app/views/submissions/show.json.jbuilder index 4ad8d9fba..d515909a5 100644 --- a/app/views/submissions/show.json.jbuilder +++ b/app/views/submissions/show.json.jbuilder @@ -5,7 +5,7 @@ json.files @submission.files do |file| json.extract! file, :id, :file_id end unless @embed_options[:disable_download] - json.render_url @submission.collect_files.select(&:visible) do |files| + json.render_url @submission.collect_files.select(&:visible?) do |files| host = ApplicationController::RENDER_HOST || request.host url = render_submission_url(@submission, files.filepath, host:) diff --git a/lib/java21_study.rb b/lib/java21_study.rb index bf5340b82..27c58ce9e 100644 --- a/lib/java21_study.rb +++ b/lib/java21_study.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true class Java21Study - def self.get_for(exercise) + def self.get_for?(exercise) java21_collection = ExerciseCollection.find_by(name: 'java2021', id: 13) exercise.exercise_collections.include? java21_collection end def self.show_tips_intervention?(user, exercise) - java21_exercise = get_for(exercise) + java21_exercise = get_for?(exercise) return false unless java21_exercise # Exercise is not part of the experiment user_group = UserGroupSeparator.get_intervention_group(user.id) @@ -16,7 +16,7 @@ def self.show_tips_intervention?(user, exercise) end def self.show_break_intervention?(user, exercise) - java21_exercise = get_for(exercise) + java21_exercise = get_for?(exercise) return false unless java21_exercise # Exercise is not part of the experiment user_group = UserGroupSeparator.get_intervention_group(user.id) @@ -24,7 +24,7 @@ def self.show_break_intervention?(user, exercise) end def self.allow_redirect_to_community_solution?(user, exercise) - java21_exercise = get_for(exercise) + java21_exercise = get_for?(exercise) return false unless java21_exercise # Exercise is not part of the experiment user_group = UserGroupSeparator.get_community_solution_group(user.id) diff --git a/spec/system/editor_system_spec.rb b/spec/system/editor_system_spec.rb index aa6322a5a..11a093061 100644 --- a/spec/system/editor_system_spec.rb +++ b/spec/system/editor_system_spec.rb @@ -44,7 +44,7 @@ it 'displays all visible files in a file tree' do within('#files') do - exercise.files.select(&:visible).each do |file| + exercise.files.select(&:visible?).each do |file| expect(page).to have_content(file.name_with_extension) end end