From ce57019971f64ea7b32aee81aa8e8d3b5a144fb6 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Fri, 24 Jan 2025 23:22:48 +0100 Subject: [PATCH] Fix Rubocop offenses --- app/controllers/codeharbor_links_controller.rb | 2 +- app/controllers/comments_controller.rb | 4 ++-- app/controllers/internal_users_controller.rb | 2 +- app/controllers/programming_groups_controller.rb | 2 +- app/controllers/request_for_comments_controller.rb | 2 +- app/controllers/study_groups_controller.rb | 2 +- .../webauthn_credential_authentication_controller.rb | 2 +- app/controllers/webauthn_credentials_controller.rb | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/codeharbor_links_controller.rb b/app/controllers/codeharbor_links_controller.rb index f5d60545a..9a74eaaf3 100644 --- a/app/controllers/codeharbor_links_controller.rb +++ b/app/controllers/codeharbor_links_controller.rb @@ -64,6 +64,6 @@ def set_user_and_authorize end def codeharbor_link_params - params.require(:codeharbor_link).permit(:push_url, :check_uuid_url, :api_key) + params.expect(codeharbor_link: %i[push_url check_uuid_url api_key]) end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index a6b00707e..fcd6032cb 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -75,7 +75,7 @@ def set_comment end def comment_params_for_update - params.require(:comment).permit(:text) + params.expect(comment: [:text]) end def comment_params_without_request_id @@ -83,7 +83,7 @@ def comment_params_without_request_id end def comment_params - params.require(:comment).permit(:file_id, :row, :column, :text, :request_id).merge(user: current_user) + params.expect(comment: %i[file_id row column text request_id]).merge(user: current_user) end def send_mail_to_author(comment, request_for_comment) diff --git a/app/controllers/internal_users_controller.rb b/app/controllers/internal_users_controller.rb index c22a44546..41d538092 100644 --- a/app/controllers/internal_users_controller.rb +++ b/app/controllers/internal_users_controller.rb @@ -112,7 +112,7 @@ def deliver_reset_password_instructions end def internal_user_params - permitted_params = params.require(:internal_user).permit(:consumer_id, :email, :name, study_group_ids: []).presence || {} + permitted_params = params.expect(internal_user: [:consumer_id, :email, :name, {study_group_ids: []}]).presence || {} checked_study_group_memberships = @study_group_memberships.select {|sgm| permitted_params[:study_group_ids]&.include? sgm.study_group.id.to_s } removed_study_group_memberships = @study_group_memberships.reject {|sgm| permitted_params[:study_group_ids]&.include? sgm.study_group.id.to_s } diff --git a/app/controllers/programming_groups_controller.rb b/app/controllers/programming_groups_controller.rb index 04f378202..d1304202b 100644 --- a/app/controllers/programming_groups_controller.rb +++ b/app/controllers/programming_groups_controller.rb @@ -106,7 +106,7 @@ def authorize! end def programming_group_params - params.require(:programming_group).permit(:programming_partner_ids, programming_group_membership_ids: []) if params[:programming_group].present? + params.expect(programming_group: [:programming_partner_ids, {programming_group_membership_ids: []}]) if params[:programming_group].present? end def set_exercise_and_authorize diff --git a/app/controllers/request_for_comments_controller.rb b/app/controllers/request_for_comments_controller.rb index acfa0389c..f446148c0 100644 --- a/app/controllers/request_for_comments_controller.rb +++ b/app/controllers/request_for_comments_controller.rb @@ -171,7 +171,7 @@ def set_request_for_comment def request_for_comment_params # The study_group_id might not be present in the session (e.g. for internal users), resulting in session[:study_group_id] = nil which is intended. - params.require(:request_for_comment).permit(:exercise_id, :file_id, :question, :requested_at, :solved, :submission_id).merge(user: current_user) + params.expect(request_for_comment: %i[exercise_id file_id question requested_at solved submission_id]).merge(user: current_user) end # The index page requires the grouping of the study groups diff --git a/app/controllers/study_groups_controller.rb b/app/controllers/study_groups_controller.rb index c0afbe711..443457d09 100644 --- a/app/controllers/study_groups_controller.rb +++ b/app/controllers/study_groups_controller.rb @@ -32,7 +32,7 @@ def destroy end def study_group_params - params.require(:study_group).permit(:name, study_group_membership_ids: []) + params.expect(study_group: [:name, {study_group_membership_ids: []}]) end private :study_group_params diff --git a/app/controllers/webauthn_credential_authentication_controller.rb b/app/controllers/webauthn_credential_authentication_controller.rb index c2f9ff4e2..76171253f 100644 --- a/app/controllers/webauthn_credential_authentication_controller.rb +++ b/app/controllers/webauthn_credential_authentication_controller.rb @@ -65,7 +65,7 @@ def deny_access_for_users_without_webauthn_credentials def credential_param return @credential_param if defined? @credential_param - credential_param = params.require(:webauthn_credential).permit(:credential)[:credential] + credential_param = params.expect(webauthn_credential: [:credential])[:credential] @credential_param = JSON.parse(credential_param.to_s) rescue JSON::ParserError @credential_param = {} diff --git a/app/controllers/webauthn_credentials_controller.rb b/app/controllers/webauthn_credentials_controller.rb index 9eabe54ca..e03b997e1 100644 --- a/app/controllers/webauthn_credentials_controller.rb +++ b/app/controllers/webauthn_credentials_controller.rb @@ -121,7 +121,7 @@ def set_webauthn_credential end def webauthn_credential_params - params.require(:webauthn_credential).permit(:credential, :label) + params.expect(webauthn_credential: %i[credential label]) end def credential_param