From 02f0b55c058de1050c67b423e969489fa6d56099 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Wed, 14 Oct 2026 13:50:45 -0600 Subject: [PATCH] RUBY-3983 Enable Lint/UnreachableLoop cop The two remaining offenses are intentional each+break loops in the specs that exercise partial cursor iteration, so they are suppressed inline rather than rewritten. --- .rubocop_todo.yml | 8 -------- spec/integration/query_cache_spec.rb | 2 +- spec/mongo/cursor_spec.rb | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 11bb45a214..6a912e2d20 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -61,14 +61,6 @@ Lint/UnreachableCode: - 'lib/mongo/protocol/serializers.rb' - 'spec/runners/unified/test.rb' -# Offense count: 2 -# Configuration parameters: AllowedPatterns. -# AllowedPatterns: (?-mix:(exactly|at_least|at_most)\(\d+\)\.times) -Lint/UnreachableLoop: - Exclude: - - 'spec/integration/query_cache_spec.rb' - - 'spec/mongo/cursor_spec.rb' - # Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions. diff --git a/spec/integration/query_cache_spec.rb b/spec/integration/query_cache_spec.rb index 935e311ca2..63f9c9d9a9 100644 --- a/spec/integration/query_cache_spec.rb +++ b/spec/integration/query_cache_spec.rb @@ -1190,7 +1190,7 @@ context 'using each & break' do let(:partial_first_iteration) do called = false - authorized_collection.find.each do + authorized_collection.find.each do # rubocop:disable Lint/UnreachableLoop -- iterate a single document called = true break end diff --git a/spec/mongo/cursor_spec.rb b/spec/mongo/cursor_spec.rb index ba79b050eb..10c8446932 100644 --- a/spec/mongo/cursor_spec.rb +++ b/spec/mongo/cursor_spec.rb @@ -656,7 +656,7 @@ context 'after #each was called once' do before do - cursor.each do |_doc| + cursor.each do |_doc| # rubocop:disable Lint/UnreachableLoop -- partially iterate on purpose break end end