From 661bebdc00965547594fa749e9327c6085c4791d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 12:35:35 +0000 Subject: [PATCH 1/4] Bump rubocop-rails from 2.27.0 to 2.28.0 in the rubocop group Bumps the rubocop group with 1 update: [rubocop-rails](https://github.com/rubocop/rubocop-rails). Updates `rubocop-rails` from 2.27.0 to 2.28.0 - [Release notes](https://github.com/rubocop/rubocop-rails/releases) - [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.27.0...v2.28.0) --- updated-dependencies: - dependency-name: rubocop-rails dependency-type: direct:development update-type: version-update:semver-minor dependency-group: rubocop ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index bfc1cf9323..cb7814d18e 100644 --- a/Gemfile +++ b/Gemfile @@ -180,7 +180,7 @@ group :development do gem 'rubocop-capybara', '~> 2.21.0' gem 'rubocop-factory_bot', '~> 2.26' gem 'rubocop-minitest', '~> 0.36.0' - gem 'rubocop-rails', '~> 2.27.0' + gem 'rubocop-rails', '~> 2.28.0' # for opening letters gem 'letter_opener', '~> 1.10.0' diff --git a/Gemfile.lock b/Gemfile.lock index 5008d248db..eead09cab4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,7 +91,7 @@ GEM bcrypt (3.1.20) bcrypt_pbkdf (1.1.1) benchmark (0.4.0) - bigdecimal (3.1.8) + bigdecimal (3.1.9) bindata (2.5.0) bindex (0.8.1) bootsnap (1.18.4) @@ -236,7 +236,7 @@ GEM activesupport (>= 5.0.0) jsbundling-rails (1.3.1) railties (>= 6.0.0) - json (2.7.4) + json (2.9.1) json-jwt (1.16.6) activesupport (>= 4.2) aes_key_wrap @@ -267,7 +267,7 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.3) + logger (1.6.4) loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -355,7 +355,7 @@ GEM orm_adapter (0.5.0) ostruct (0.6.0) parallel (1.26.3) - parser (3.3.5.0) + parser (3.3.6.0) ast (~> 2.4.1) racc premailer (1.18.0) @@ -440,7 +440,7 @@ GEM rb-readline (0.5.5) rdoc (6.8.1) psych (>= 4.0.0) - regexp_parser (2.9.2) + regexp_parser (2.10.0) reline (0.5.11) io-console (~> 0.5) responders (3.1.1) @@ -448,17 +448,17 @@ GEM railties (>= 5.2) rexml (3.3.9) rouge (4.5.1) - rubocop (1.67.0) + rubocop (1.69.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rubocop-ast (>= 1.32.2, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.36.2, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.3) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.37.0) parser (>= 3.3.1.0) rubocop-capybara (2.21.0) rubocop (~> 1.41) @@ -467,7 +467,7 @@ GEM rubocop-minitest (0.36.0) rubocop (>= 1.61, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.27.0) + rubocop-rails (2.28.0) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.52.0, < 2.0) @@ -533,7 +533,9 @@ GEM trilogy (2.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.6.0) + unicode-display_width (3.1.3) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) uri (0.13.1) useragent (0.16.10) validate_url (1.0.15) @@ -633,7 +635,7 @@ DEPENDENCIES rubocop-capybara (~> 2.21.0) rubocop-factory_bot (~> 2.26) rubocop-minitest (~> 0.36.0) - rubocop-rails (~> 2.27.0) + rubocop-rails (~> 2.28.0) ruby-saml (~> 1.17.0) rubyzip (~> 2.3.2) selenium-webdriver (~> 4.27.0) From e80e5c9b4e71f111f4712c8681f00c749014f069 Mon Sep 17 00:00:00 2001 From: "jorg.vr" Date: Thu, 2 Jan 2025 12:05:29 +0100 Subject: [PATCH 2/4] Fix style --- app/controllers/activities_controller.rb | 2 +- app/controllers/course_members_controller.rb | 2 +- app/policies/evaluation_exercise_policy.rb | 7 +++++-- app/policies/evaluation_policy.rb | 5 ++++- app/policies/feedback_policy.rb | 5 ++++- app/policies/score_policy.rb | 7 +++++-- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index f1ee8a07f4..f10d5e0aa9 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -185,7 +185,7 @@ def update if labels labels = labels&.split(',') unless labels.is_a?(Array) labels = (labels + (@activity.merged_dirconfig[:labels] || [])) - attributes[:labels] = labels&.map(&:downcase)&.uniq&.map { |name| Label.find_by(name: name) || Label.create(name: name) } + attributes[:labels] = labels.map(&:downcase).uniq.map { |name| Label.find_by(name: name) || Label.create(name: name) } if labels end respond_to do |format| diff --git a/app/controllers/course_members_controller.rb b/app/controllers/course_members_controller.rb index d1a8bacc6e..b403da5920 100644 --- a/app/controllers/course_members_controller.rb +++ b/app/controllers/course_members_controller.rb @@ -74,7 +74,7 @@ def update course_labels = attributes[:course_labels] if course_labels course_labels = course_labels.split(',') unless course_labels.is_a?(Array) - attributes[:course_labels] = course_labels&.map(&:downcase)&.uniq&.map { |name| CourseLabel.find_by(course: @course, name: name) || CourseLabel.create(course: @course, name: name) } + attributes[:course_labels] = course_labels.map(&:downcase).uniq.map { |name| CourseLabel.find_by(course: @course, name: name) || CourseLabel.create(course: @course, name: name) } if course_labels end if @course_membership.update(attributes) diff --git a/app/policies/evaluation_exercise_policy.rb b/app/policies/evaluation_exercise_policy.rb index 5bdfb25a1f..9c4bd8885f 100644 --- a/app/policies/evaluation_exercise_policy.rb +++ b/app/policies/evaluation_exercise_policy.rb @@ -17,7 +17,10 @@ def update? private def course_admin? - course = record&.evaluation&.series&.course - user&.course_admin?(course) + return false unless user + return false unless record + + course = record.evaluation.series.course + user.course_admin?(course) end end diff --git a/app/policies/evaluation_policy.rb b/app/policies/evaluation_policy.rb index 1b621d78c5..0c8357dd22 100644 --- a/app/policies/evaluation_policy.rb +++ b/app/policies/evaluation_policy.rb @@ -62,6 +62,9 @@ def permitted_attributes private def course_admin? - user&.course_admin?(record&.series&.course) + return false unless user + return false unless record + + user.course_admin?(record.series.course) end end diff --git a/app/policies/feedback_policy.rb b/app/policies/feedback_policy.rb index a6147ae11f..a7337a78d2 100644 --- a/app/policies/feedback_policy.rb +++ b/app/policies/feedback_policy.rb @@ -39,6 +39,9 @@ def permitted_attributes private def course_admin? - user&.course_admin?(record&.evaluation&.series&.course) + return false unless user + return false unless record + + user.course_admin?(record.evaluation.series.course) end end diff --git a/app/policies/score_policy.rb b/app/policies/score_policy.rb index 9b97e91988..978503a1ea 100644 --- a/app/policies/score_policy.rb +++ b/app/policies/score_policy.rb @@ -42,7 +42,10 @@ def permitted_attributes_for_update private def course_admin? - course = record&.feedback&.evaluation&.series&.course - user&.course_admin?(course) + return false unless user + return false unless record + + course = record.feedback.evaluation.series.course + user.course_admin?(course) end end From d391b633cacbac13e81842ac9ed683d8dcbae1ca Mon Sep 17 00:00:00 2001 From: "jorg.vr" Date: Tue, 7 Jan 2025 17:07:51 +0100 Subject: [PATCH 3/4] Revert "Fix style" This reverts commit e80e5c9b4e71f111f4712c8681f00c749014f069. --- app/controllers/activities_controller.rb | 2 +- app/controllers/course_members_controller.rb | 2 +- app/policies/evaluation_exercise_policy.rb | 7 ++----- app/policies/evaluation_policy.rb | 5 +---- app/policies/feedback_policy.rb | 5 +---- app/policies/score_policy.rb | 7 ++----- 6 files changed, 8 insertions(+), 20 deletions(-) diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index f10d5e0aa9..f1ee8a07f4 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -185,7 +185,7 @@ def update if labels labels = labels&.split(',') unless labels.is_a?(Array) labels = (labels + (@activity.merged_dirconfig[:labels] || [])) - attributes[:labels] = labels.map(&:downcase).uniq.map { |name| Label.find_by(name: name) || Label.create(name: name) } if labels + attributes[:labels] = labels&.map(&:downcase)&.uniq&.map { |name| Label.find_by(name: name) || Label.create(name: name) } end respond_to do |format| diff --git a/app/controllers/course_members_controller.rb b/app/controllers/course_members_controller.rb index b403da5920..d1a8bacc6e 100644 --- a/app/controllers/course_members_controller.rb +++ b/app/controllers/course_members_controller.rb @@ -74,7 +74,7 @@ def update course_labels = attributes[:course_labels] if course_labels course_labels = course_labels.split(',') unless course_labels.is_a?(Array) - attributes[:course_labels] = course_labels.map(&:downcase).uniq.map { |name| CourseLabel.find_by(course: @course, name: name) || CourseLabel.create(course: @course, name: name) } if course_labels + attributes[:course_labels] = course_labels&.map(&:downcase)&.uniq&.map { |name| CourseLabel.find_by(course: @course, name: name) || CourseLabel.create(course: @course, name: name) } end if @course_membership.update(attributes) diff --git a/app/policies/evaluation_exercise_policy.rb b/app/policies/evaluation_exercise_policy.rb index 9c4bd8885f..5bdfb25a1f 100644 --- a/app/policies/evaluation_exercise_policy.rb +++ b/app/policies/evaluation_exercise_policy.rb @@ -17,10 +17,7 @@ def update? private def course_admin? - return false unless user - return false unless record - - course = record.evaluation.series.course - user.course_admin?(course) + course = record&.evaluation&.series&.course + user&.course_admin?(course) end end diff --git a/app/policies/evaluation_policy.rb b/app/policies/evaluation_policy.rb index 0c8357dd22..1b621d78c5 100644 --- a/app/policies/evaluation_policy.rb +++ b/app/policies/evaluation_policy.rb @@ -62,9 +62,6 @@ def permitted_attributes private def course_admin? - return false unless user - return false unless record - - user.course_admin?(record.series.course) + user&.course_admin?(record&.series&.course) end end diff --git a/app/policies/feedback_policy.rb b/app/policies/feedback_policy.rb index 92b16e20b8..ec29c28d2b 100644 --- a/app/policies/feedback_policy.rb +++ b/app/policies/feedback_policy.rb @@ -37,9 +37,6 @@ def permitted_attributes private def course_admin? - return false unless user - return false unless record - - user.course_admin?(record.evaluation.series.course) + user&.course_admin?(record&.evaluation&.series&.course) end end diff --git a/app/policies/score_policy.rb b/app/policies/score_policy.rb index 978503a1ea..9b97e91988 100644 --- a/app/policies/score_policy.rb +++ b/app/policies/score_policy.rb @@ -42,10 +42,7 @@ def permitted_attributes_for_update private def course_admin? - return false unless user - return false unless record - - course = record.feedback.evaluation.series.course - user.course_admin?(course) + course = record&.feedback&.evaluation&.series&.course + user&.course_admin?(course) end end From 158cec012a5a879a527435e4d816df2b5b65bd8c Mon Sep 17 00:00:00 2001 From: "jorg.vr" Date: Tue, 7 Jan 2025 17:10:02 +0100 Subject: [PATCH 4/4] Ignore new style warning --- .rubocop.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 4b111e424c..c62a35215b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -87,6 +87,8 @@ Style/OptionalBooleanParameter: Enabled: false Style/HashSyntax: EnforcedShorthandSyntax: never +Style/SafeNavigationChainLength: + Max: 4 FactoryBot/ConsistentParenthesesStyle: EnforcedStyle: omit_parentheses