Skip to content

Commit 576a40b

Browse files
committed
Disable the Lint/LiteralAsCondition rule since it incorrectly flags while true
1 parent dbb4574 commit 576a40b

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

.rubocop.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,8 @@ Lint/InheritException:
179179

180180
Lint/LiteralAsCondition:
181181
Description: Checks of literals used in conditions.
182-
Details: >-
183-
Pattern `while true` is allowed, disable the cop with
184-
`while true # rubocop:disable Lint/LiteralAsCondition` in this case.
185-
Enabled: true
182+
# disabled, it prevents `while true`, which is useful
183+
Enabled: false
186184

187185
# Supports --auto-correct
188186
Lint/LiteralInInterpolation:

src/main/ruby/truffleruby/core/array.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ def sample(count=undefined, options=undefined)
10421042
k = rng.rand(size)
10431043
spin = false
10441044

1045-
while true # rubocop:disable Lint/LiteralAsCondition
1045+
while true
10461046
j = 0
10471047
while j < i
10481048
if k == result[j]
@@ -1085,7 +1085,7 @@ def sample(count=undefined, options=undefined)
10851085
while i < count
10861086
k = rng.rand(size)
10871087

1088-
while true # rubocop:disable Lint/LiteralAsCondition
1088+
while true
10891089
if result_set.include?(k)
10901090
k = rng.rand(size)
10911091
else

src/main/ruby/truffleruby/core/enumerable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def cycle(many=nil)
537537
i += 1
538538
end
539539
else
540-
while true # rubocop:disable Lint/LiteralAsCondition
540+
while true
541541
cache.each { |o| yield o }
542542
end
543543
end

src/main/ruby/truffleruby/core/kernel.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def loop
434434
return to_enum(:loop) { Float::INFINITY } unless block_given?
435435

436436
begin
437-
while true # rubocop:disable Lint/LiteralAsCondition
437+
while true
438438
yield
439439
end
440440
rescue StopIteration => si

src/main/ruby/truffleruby/core/posix.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def self.with_array_of_strings_pointer(strings)
346346
# gets as soon as it gets something.
347347

348348
def self.read_string_at_least_one_byte(io, count)
349-
while true # rubocop:disable Lint/LiteralAsCondition
349+
while true
350350
# must call #read_string in order to properly support polyglot STDIO
351351
string, errno = read_string(io, count)
352352
return string if errno == 0

src/main/ruby/truffleruby/core/range.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
# rubocop:disable Lint/LiteralAsCondition
30-
3129
class Range
3230

3331
include Enumerable

0 commit comments

Comments
 (0)