Maintenance: Updated rubocop(-* gems) to latest version (1.6.1).

This commit is contained in:
Thorsten Eckel 2020-12-10 10:13:57 +01:00
parent 51df6d458d
commit f97a1d9211
9 changed files with 30 additions and 14 deletions

View file

@ -452,13 +452,13 @@ GEM
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
rszr (0.5.2)
rubocop (1.4.2)
rubocop (1.6.1)
parallel (~> 1.10)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.1.1)
rubocop-ast (>= 1.2.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.3.0)
@ -466,10 +466,10 @@ GEM
rubocop-performance (1.9.1)
rubocop (>= 0.90.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.8.1)
rubocop-rails (2.9.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 0.87.0)
rubocop (>= 0.90.0, < 2.0)
rubocop-rspec (2.0.1)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)

View file

@ -17,9 +17,9 @@ module HasTranslations
output = eager_load(:translations).joins(translations: { kb_locale: :knowledge_base })
if system_locale_or_id.present?
output.where('knowledge_base_locales.system_locale_id = ?', system_locale_or_id)
output.where('knowledge_base_locales.system_locale_id' => system_locale_or_id)
else
output.where('knowledge_base_locales.system_locale_id = ?', -1)
output.where('knowledge_base_locales.system_locale_id' => -1)
end
}
end

View file

@ -467,7 +467,7 @@ returns
=end
def self.discard_changes
ObjectManager::Attribute.where('to_create = ?', true).each(&:destroy)
ObjectManager::Attribute.where(to_create: true).each(&:destroy)
ObjectManager::Attribute.where('to_delete = ? OR to_config = ?', true, true).each do |attribute|
attribute.to_migrate = false
attribute.to_delete = false

View file

@ -37,7 +37,7 @@ class Scheduler < ApplicationModel
end
# read/load jobs and check if each has already been started
jobs = Scheduler.where('active = ?', true).order(prio: :asc)
jobs = Scheduler.where(active: true).order(prio: :asc)
jobs.each do |job|
# ignore job is still running

View file

@ -111,7 +111,7 @@ returns
agents = {}
agent_role_ids = Role.with_permissions('ticket.agent').pluck(:id)
agent_user_ids = User.joins(:roles).where(users: { active: true }).where('roles_users.role_id IN (?)', agent_role_ids).pluck(:id)
agent_user_ids = User.joins(:roles).where(users: { active: true }).where('roles_users.role_id' => agent_role_ids).pluck(:id)
groups.each do |group|
filter[:group_id].push group.id
assets = group.assets(assets)

View file

@ -680,7 +680,7 @@ returns
def self.of_role(role, group_ids = nil)
roles_ids = Role.where(active: true, name: role).map(&:id)
if !group_ids
return User.where(active: true).joins(:users_roles).where('roles_users.role_id IN (?)', roles_ids).order('users.updated_at DESC')
return User.where(active: true).joins(:users_roles).where('roles_users.role_id' => roles_ids).order('users.updated_at DESC')
end
User.where(active: true)

View file

@ -6,15 +6,15 @@ class Issue1977RemoveInvalidUserForeignKeys < ActiveRecord::Migration[5.1]
# cleanup
OnlineNotification.joins('LEFT OUTER JOIN users ON online_notifications.user_id = users.id')
.where('users.id IS NULL')
.where('users.id' => nil)
.destroy_all
RecentView.joins('LEFT OUTER JOIN users ON recent_views.created_by_id = users.id')
.where('users.id IS NULL')
.where('users.id' => nil)
.destroy_all
Avatar.joins('LEFT OUTER JOIN users ON avatars.o_id = users.id')
.where('users.id IS NULL')
.where('users.id' => nil)
.where(object_lookup_id: ObjectLookup.by_name('User'))
.destroy_all

View file

@ -26,6 +26,7 @@ class InitializeKnowledgeBase < ActiveRecord::Migration[5.0]
t.timestamps null: false # rubocop:disable Zammad/ExistsDateTimePrecision
end
add_index :knowledge_base_locales, %i[system_locale_id knowledge_base_id], name: 'index_kb_locale_on_kb_system_locale_kb', unique: true
create_table :knowledge_base_translations do |t|
t.string :title, limit: 250, null: false
@ -36,6 +37,7 @@ class InitializeKnowledgeBase < ActiveRecord::Migration[5.0]
t.timestamps null: false # rubocop:disable Zammad/ExistsDateTimePrecision
end
add_index :knowledge_base_translations, %i[kb_locale_id knowledge_base_id], name: 'index_kb_t_on_kb_locale_kb', unique: true
create_table :knowledge_base_categories do |t|
t.references :knowledge_base, null: false, foreign_key: { to_table: :knowledge_bases }
@ -55,6 +57,7 @@ class InitializeKnowledgeBase < ActiveRecord::Migration[5.0]
t.timestamps null: false # rubocop:disable Zammad/ExistsDateTimePrecision
end
add_index :knowledge_base_category_translations, %i[kb_locale_id category_id], name: 'index_kb_c_t_on_kb_locale_category', unique: true
create_table :knowledge_base_answers do |t|
t.references :category, null: false, foreign_key: { to_table: :knowledge_base_categories }
@ -89,6 +92,7 @@ class InitializeKnowledgeBase < ActiveRecord::Migration[5.0]
t.timestamps null: false # rubocop:disable Zammad/ExistsDateTimePrecision
end
add_index :knowledge_base_answer_translations, %i[kb_locale_id answer_id], name: 'index_kb_a_t_on_kb_locale_answer', unique: true
create_table :knowledge_base_menu_items do |t|
t.references :kb_locale, null: false, foreign_key: { to_table: :knowledge_base_locales, on_delete: :cascade }

View file

@ -0,0 +1,12 @@
class MaintenanceMissingKbUniqueIndexes < ActiveRecord::Migration[5.2]
def change
# return if it's a new setup
return if !Setting.exists?(name: 'system_init_done')
add_index :knowledge_base_locales, %i[system_locale_id knowledge_base_id], name: 'index_kb_locale_on_kb_system_locale_kb', unique: true
add_index :knowledge_base_translations, %i[kb_locale_id knowledge_base_id], name: 'index_kb_t_on_kb_locale_kb', unique: true
add_index :knowledge_base_category_translations, %i[kb_locale_id category_id], name: 'index_kb_c_t_on_kb_locale_category', unique: true
add_index :knowledge_base_answer_translations, %i[kb_locale_id answer_id], name: 'index_kb_a_t_on_kb_locale_answer', unique: true
end
end