Add and apply Style/CollectionQuerying rubocop rule
This rule was added in rubocop 1.77. We were following it most of the time. It makes the code more readable in my humble opinion.
This commit is contained in:
@@ -747,6 +747,9 @@ Style/ClassVars:
|
||||
Style/CollectionMethods:
|
||||
Enabled: true
|
||||
|
||||
Style/CollectionQuerying:
|
||||
Enabled: true
|
||||
|
||||
Style/ComparableBetween:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class Layout::NotificationItemComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def notifications_class
|
||||
if unread_notifications.count > 0
|
||||
if unread_notifications.any?
|
||||
"unread-notifications"
|
||||
else
|
||||
"no-notifications"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module DebatesHelper
|
||||
def has_featured?
|
||||
Debate.all.featured.count > 0
|
||||
Debate.all.featured.any?
|
||||
end
|
||||
|
||||
def empty_recommended_debates_message_text(user)
|
||||
|
||||
@@ -6,11 +6,11 @@ class PollOptionFinder
|
||||
end
|
||||
|
||||
def manageable_choices
|
||||
choices_map.select { |choice, ids| ids.count == 1 }
|
||||
choices_map.select { |choice, ids| ids.one? }
|
||||
end
|
||||
|
||||
def unmanageable_choices
|
||||
choices_map.reject { |choice, ids| ids.count == 1 }
|
||||
choices_map.reject { |choice, ids| ids.one? }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -37,7 +37,7 @@ class Budget
|
||||
end
|
||||
|
||||
def has_lines_with_no_heading?
|
||||
investments.no_heading.count > 0
|
||||
investments.no_heading.any?
|
||||
end
|
||||
|
||||
def has_lines_with_heading?
|
||||
|
||||
@@ -84,7 +84,7 @@ module Globalizable
|
||||
length: options[:length],
|
||||
if: lambda { |translation| translation.locale == Setting.default_locale }
|
||||
end
|
||||
if options.count > 1
|
||||
if options.many?
|
||||
translation_class.instance_eval do
|
||||
validates method, options.reject { |key| key == :length }
|
||||
end
|
||||
|
||||
@@ -42,7 +42,7 @@ class Verification::Management::Email
|
||||
private
|
||||
|
||||
def validate_user
|
||||
return if errors.count > 0
|
||||
return if errors.any?
|
||||
|
||||
if !user?
|
||||
errors.add(:email, I18n.t("errors.messages.user_not_found"))
|
||||
@@ -52,7 +52,7 @@ class Verification::Management::Email
|
||||
end
|
||||
|
||||
def validate_document_number
|
||||
return if errors.count > 0
|
||||
return if errors.any?
|
||||
|
||||
if document_number_mismatch?
|
||||
errors.add(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Default admin user (change password after first deploy to a server!)
|
||||
if Administrator.count == 0 && (!Rails.env.test? || !Tenant.default?)
|
||||
if Administrator.none? && (!Rails.env.test? || !Tenant.default?)
|
||||
admin = User.create!(username: "admin", email: "admin@consul.dev", password: "12345678",
|
||||
password_confirmation: "12345678", confirmed_at: Time.current,
|
||||
terms_of_service: "1")
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace :polls do
|
||||
option_finder.unmanageable_choices.each do |choice, ids|
|
||||
tenant_info = " on tenant #{Tenant.current_schema}" unless Tenant.default?
|
||||
|
||||
if ids.count == 0
|
||||
if ids.none?
|
||||
logger.warn "Skipping poll_answers with the text \"#{choice}\" for the poll_question " \
|
||||
"with ID #{question.id}. This question has no poll_question_answers " \
|
||||
"containing the text \"#{choice}\"" + tenant_info.to_s
|
||||
@@ -185,7 +185,7 @@ namespace :polls do
|
||||
option_finder.unmanageable_choices.each do |choice, ids|
|
||||
tenant_info = " on tenant #{Tenant.current_schema}" unless Tenant.default?
|
||||
|
||||
if ids.count == 0
|
||||
if ids.none?
|
||||
logger.warn "Skipping poll_partial_results with the text \"#{choice}\" for the poll_question " \
|
||||
"with ID #{question.id}. This question has no poll_question_answers " \
|
||||
"containing the text \"#{choice}\"" + tenant_info.to_s
|
||||
|
||||
Reference in New Issue
Block a user