Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump rubocop-rails from 2.25.1 to 2.26.0 in the rubocop group #5746

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ group :development do
gem 'rubocop-capybara', '~> 2.21.0'
gem 'rubocop-factory_bot', '~> 2.26'
gem 'rubocop-minitest', '~> 0.35.1'
gem 'rubocop-rails', '~> 2.25.1'
gem 'rubocop-rails', '~> 2.26.0'

# for opening letters
gem 'letter_opener', '~> 1.10.0'
Expand Down
20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ GEM
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
childprocess (5.0.0)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
counter_culture (3.7.0)
activerecord (>= 4.2)
Expand Down Expand Up @@ -284,7 +284,7 @@ GEM
memory_profiler (1.0.2)
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.24.1)
minitest (5.25.1)
minitest-ci (3.4.0)
minitest (>= 5.0.6)
minitest-utils (0.4.8)
Expand Down Expand Up @@ -355,8 +355,8 @@ GEM
validate_url
webfinger (~> 2.0)
orm_adapter (0.5.0)
parallel (1.25.1)
parser (3.3.4.0)
parallel (1.26.3)
parser (3.3.4.2)
ast (~> 2.4.1)
racc
premailer (1.18.0)
Expand Down Expand Up @@ -446,10 +446,10 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.3)
rexml (3.3.6)
strscan
rouge (4.3.0)
rubocop (1.65.0)
rubocop (1.65.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -460,7 +460,7 @@ GEM
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
rubocop-ast (1.32.1)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
Expand All @@ -469,10 +469,10 @@ GEM
rubocop-minitest (0.35.1)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.25.1)
rubocop-rails (2.26.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
ruby-saml (1.16.0)
Expand Down Expand Up @@ -633,7 +633,7 @@ DEPENDENCIES
rubocop-capybara (~> 2.21.0)
rubocop-factory_bot (~> 2.26)
rubocop-minitest (~> 0.35.1)
rubocop-rails (~> 2.25.1)
rubocop-rails (~> 2.26.0)
ruby-saml (~> 1.16.0)
rubyzip (~> 2.3.2)
selenium-webdriver (~> 4.23.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def user_not_authorized
elsif current_user.nil?
redirect_to sign_in_path
else
flash[:alert] = I18n.t('errors.no_rights')
flash[:alert] = I18n.t('errors.no_rights') # rubocop:disable Rails/ActionControllerFlashBeforeRender
if request.referer.present? && URI.parse(request.referer).host == request.host
redirect_to(request.referer)
else
Expand Down
4 changes: 2 additions & 2 deletions app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class Activity < ApplicationRecord
MEDIA_DIR = File.join(DESCRIPTION_DIR, 'media').freeze

# We need to prefix, otherwise Rails can't generate the public? method
enum access: { public: 0, private: 1 }, _prefix: true
enum status: { ok: 0, not_valid: 1, removed: 2 }
enum :access, { public: 0, private: 1 }, prefix: true
enum :status, { ok: 0, not_valid: 1, removed: 2 }

belongs_to :repository
belongs_to :judge, optional: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/activity_read_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ActivityReadState < ApplicationRecord
scope :by_activity_name, ->(name) { where(activity: Activity.by_name(name)) }
scope :by_username, ->(name) { where(user: User.by_filter(name)) }
scope :by_filter, lambda { |filter, skip_user:, skip_content_page:|
filter.split.map(&:strip).select(&:present?).map do |part|
filter.split.map(&:strip).compact_blank.map do |part|
scopes = []
scopes << by_activity_name(part) unless skip_content_page
scopes << by_username(part) unless skip_user
Expand Down
2 changes: 1 addition & 1 deletion app/models/annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Annotation < ApplicationRecord
after_save :create_notification

scope :by_filter, lambda { |filter, skip_user:, skip_exercise:|
filter.split.map(&:strip).select(&:present?).map do |part|
filter.split.map(&:strip).compact_blank.map do |part|
scopes = []
scopes << by_exercise_name(part) unless skip_exercise
scopes << by_username(part) unless skip_user
Expand Down
4 changes: 2 additions & 2 deletions app/models/announcement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
class Announcement < ApplicationRecord
has_many :announcement_views, dependent: :destroy
belongs_to :institution, optional: true
enum user_group: { everyone: 0, all_users: 1, students: 2, staff: 3, zeus: 4 }
enum style: { primary: 0, success: 1, danger: 2, warning: 3, info: 4 }
enum :user_group, { everyone: 0, all_users: 1, students: 2, staff: 3, zeus: 4 }
enum :style, { primary: 0, success: 1, danger: 2, warning: 3, info: 4 }

validates :text_nl, presence: true
validates :text_en, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/filterable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module Filterable

included do
before_save :set_search
scope :by_filter, ->(filter) { filter.split.map(&:strip).select(&:present?).inject(self) { |query, part| query.where("#{table_name}.search LIKE ?", "%#{part}%") } }
scope :by_filter, ->(filter) { filter.split.map(&:strip).compact_blank.inject(self) { |query, part| query.where("#{table_name}.search LIKE ?", "%#{part}%") } }
end
end
2 changes: 1 addition & 1 deletion app/models/concerns/gitable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Gitable
included do
before_create :fix_remote

enum clone_status: { queued: 1, running: 2, complete: 3, failed: 4 }, _prefix: :clone
enum :clone_status, { queued: 1, running: 2, complete: 3, failed: 4 }, prefix: :clone
end

def full_path
Expand Down
4 changes: 2 additions & 2 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class Course < ApplicationRecord

has_many :course_labels, dependent: :destroy

enum visibility: { visible_for_all: 0, visible_for_institution: 1, hidden: 2 }
enum registration: { open_for_all: 3, open_for_institutional_users: 0, open_for_institution: 1, closed: 2 }
enum :visibility, { visible_for_all: 0, visible_for_institution: 1, hidden: 2 }
enum :registration, { open_for_all: 3, open_for_institutional_users: 0, open_for_institution: 1, closed: 2 }

# TODO: Remove and use activities?
has_many :content_pages,
Expand Down
2 changes: 1 addition & 1 deletion app/models/course_membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#

class CourseMembership < ApplicationRecord
enum status: { pending: 0, course_admin: 1, student: 2, unsubscribed: 3 }
enum :status, { pending: 0, course_admin: 1, student: 2, unsubscribed: 3 }

belongs_to :course
belongs_to :user
Expand Down
2 changes: 1 addition & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#

class Event < ApplicationRecord
enum event_type: { rejudge: 0, permission_change: 1, exercise_repository: 2, error: 3 }
enum :event_type, { rejudge: 0, permission_change: 1, exercise_repository: 2, error: 3 }
belongs_to :user, optional: true

validates :event_type, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Export < ApplicationRecord

belongs_to :user
has_one_attached :archive
enum status: { started: 0, finished: 1, failed: 2 }
enum :status, { started: 0, finished: 1, failed: 2 }

default_scope { order(id: :desc) }

Expand Down
2 changes: 1 addition & 1 deletion app/models/institution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Institution < ApplicationRecord
IGNORED_DOMAINS_FOR_SIMILARITY = %w[gmail.com hotmail.com outlook.com yahoo.com live.com msn.com aol.com icloud.com telenet.be gmail.be live.be outlook.be hotmail.be].freeze
NEW_INSTITUTION_NAME = 'n/a'.freeze

enum category: { secondary: 0, higher: 1, other: 2 }
enum :category, { secondary: 0, higher: 1, other: 2 }

has_many :users, dependent: :restrict_with_error
has_many :providers, inverse_of: :institution, dependent: :restrict_with_error
Expand Down
2 changes: 1 addition & 1 deletion app/models/label.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Label < ApplicationRecord
has_many :activity_labels, dependent: :restrict_with_error
has_many :activities, through: :activity_labels

enum color: { red: 0, pink: 1, purple: 2, 'deep-purple': 3, indigo: 4, teal: 5, orange: 6, brown: 7, 'blue-gray': 8 }
enum :color, { red: 0, pink: 1, purple: 2, 'deep-purple': 3, indigo: 4, teal: 5, orange: 6, brown: 7, 'blue-gray': 8 }

scope :by_name, ->(name) { where('name LIKE ?', "%#{name}%") }

Expand Down
2 changes: 1 addition & 1 deletion app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# jwks_uri :string(255)
#
class Provider < ApplicationRecord
enum mode: { prefer: 0, redirect: 1, link: 2, secondary: 3 }
enum :mode, { prefer: 0, redirect: 1, link: 2, secondary: 3 }

PROVIDERS = [Provider::GSuite, Provider::Lti, Provider::Office365, Provider::Oidc, Provider::Saml, Provider::Smartschool, Provider::Surf, Provider::Elixir].freeze

Expand Down
2 changes: 1 addition & 1 deletion app/models/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Question < Annotation
after_save :schedule_reset_in_progress, if: :saved_change_to_question_state?
after_commit :clear_transition

enum question_state: { unanswered: 0, in_progress: 1, answered: 2 }
enum :question_state, { unanswered: 0, in_progress: 1, answered: 2 }
alias_attribute :question_text, :annotation_text

# Used to authorize the transitions
Expand Down
2 changes: 1 addition & 1 deletion app/models/series.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Series < ApplicationRecord
USER_STARTED_CACHE_STRING = '/series/%<id>s/user/%<user_id>s/started/%<updated_at>s'.freeze
USER_WRONG_CACHE_STRING = '/series/%<id>s/user/%<user_id>s/wrong/%<updated_at>s'.freeze

enum visibility: { open: 0, hidden: 1, closed: 2, timed: 3 }
enum :visibility, { open: 0, hidden: 1, closed: 2, timed: 3 }

before_save :regenerate_activity_tokens, if: :visibility_changed?
before_create :generate_access_token
Expand Down
4 changes: 2 additions & 2 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Submission < ApplicationRecord
CODE_FILENAME = 'code'.freeze
RESULT_FILENAME = 'result.json.gz'.freeze

enum status: { unknown: 0, correct: 1, wrong: 2, 'time limit exceeded': 3, running: 4, queued: 5, 'runtime error': 6, 'compilation error': 7, 'memory limit exceeded': 8, 'internal error': 9, 'output limit exceeded': 10 }
enum :status, { unknown: 0, correct: 1, wrong: 2, 'time limit exceeded': 3, running: 4, queued: 5, 'runtime error': 6, 'compilation error': 7, 'memory limit exceeded': 8, 'internal error': 9, 'output limit exceeded': 10 }

belongs_to :exercise, optional: false
belongs_to :user, optional: false
Expand Down Expand Up @@ -70,7 +70,7 @@ class Submission < ApplicationRecord
scope :by_status, ->(status) { where(status: status.in?(statuses) ? status : -1) }
scope :by_username, ->(name) { where(user: User.by_filter(name)) }
scope :by_filter, lambda { |filter, skip_user:, skip_exercise:|
filter.split.map(&:strip).select(&:present?).map do |part|
filter.split.map(&:strip).compact_blank.map do |part|
scopes = []
scopes << by_exercise_name(part) unless skip_exercise
scopes << by_username(part) unless skip_user
Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class User < ApplicationRecord
ATTEMPTED_EXERCISES_CACHE_STRING = '/courses/%<course_id>s/user/%<id>s/attempted_exercises'.freeze
CORRECT_EXERCISES_CACHE_STRING = '/courses/%<course_id>s/user/%<id>s/correct_exercises'.freeze

enum permission: { student: 0, staff: 1, zeus: 2 }
enum theme: { system: 0, light: 1, dark: 2 }
enum :permission, { student: 0, staff: 1, zeus: 2 }
enum :theme, { system: 0, light: 1, dark: 2 }

belongs_to :institution, optional: true

Expand Down
2 changes: 1 addition & 1 deletion test/controllers/exports_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ExportsControllerTest < ActionDispatch::IntegrationTest
post series_exports_path(@series), params: { all: true, only_last_submission: true, with_info: true, format: :json }

assert_response :success
count = @students.map { |u| @series.exercises.map { |e| e.last_submission(u, @series) } }.flatten.select(&:present?).count
count = @students.map { |u| @series.exercises.map { |e| e.last_submission(u, @series) } }.flatten.compact_blank.count

assert_zip ActiveStorage::Blob.last.download, with_info: true, solution_count: count, data: @data
end
Expand Down