From 87f7670c13ab37a4e267a75cc9dfc5f6a318da05 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Tue, 10 Nov 2026 14:51:17 +0900 Subject: [PATCH] Use Array#intersect? to check whether a principal watches an object watched_by? built the intersection of two id arrays only to test it for emptiness. Array#intersect?, available since Ruby 3.1, answers that directly without allocating the intermediate array, as already done elsewhere in Redmine. The code lives under lib/plugins, which RuboCop excludes, so Style/ArrayIntersect did not catch it. Co-Authored-By: Claude Opus 5.5 --- lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb b/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb index e8f4dd32f..a97bbef53 100644 --- a/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb +++ b/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb @@ -116,7 +116,7 @@ module Redmine user_ids |= principal.group_ids if principal.is_a?(User) user_ids.compact! - (self.watcher_user_ids & user_ids).any? + watcher_user_ids.intersect?(user_ids) end def notified_watchers -- 2.55.0