Skip to content

Commit 60f21c1

Browse files
committed
(PUP-11993) Style/NegatedWhile
This commit enables Style/NegatedWhile cop and fixes 6 auto-correctable offenses.
1 parent a5b108d commit 60f21c1

File tree

7 files changed

+6
-16
lines changed

7 files changed

+6
-16
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -629,16 +629,6 @@ Style/MultipleComparison:
629629
Style/MutableConstant:
630630
Enabled: false
631631

632-
# This cop supports safe auto-correction (--auto-correct).
633-
Style/NegatedWhile:
634-
Exclude:
635-
- 'lib/puppet/file_system/file_impl.rb'
636-
- 'lib/puppet/graph/simple_graph.rb'
637-
- 'lib/puppet/http/client.rb'
638-
- 'lib/puppet/pops/parser/heredoc_support.rb'
639-
- 'lib/puppet/pops/types/p_object_type.rb'
640-
- 'lib/puppet/scheduler/scheduler.rb'
641-
642632
# This cop supports safe auto-correction (--auto-correct).
643633
Style/NestedModifier:
644634
Exclude:

lib/puppet/file_system/file_impl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def exclusive_create(path, mode, &block)
5252
def exclusive_open(path, mode, options = 'r', timeout = 300, &block)
5353
wait = 0.001 + (Kernel.rand / 1000)
5454
written = false
55-
while !written
55+
until written
5656
::File.open(path, options, mode) do |rf|
5757
if rf.flock(::File::LOCK_EX | ::File::LOCK_NB)
5858
Puppet.debug { _("Locked '%{path}'") % { path: path } }

lib/puppet/graph/simple_graph.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def tarjan(root, s)
106106
# decent Ruby stack.
107107
recur = [{ :node => root }]
108108

109-
while not recur.empty? do
109+
until recur.empty? do
110110
frame = recur.last
111111
vertex = frame[:node]
112112

lib/puppet/http/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def execute_streaming(request, options: {}, &block)
365365
response = nil
366366
done = false
367367

368-
while !done do
368+
until done do
369369
connect(request.uri, options: options) do |http|
370370
apply_auth(request, basic_auth) if redirects.zero?
371371

lib/puppet/pops/parser/heredoc_support.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def heredoc
8383
# (Endline in EBNF form): WS* ('|' WS*)? ('-' WS*)? endtag WS* \r? (\n|$)
8484
endline_pattern = /([[:blank:]]*)(?:([|])[[:blank:]]*)?(?:(\-)[[:blank:]]*)?#{Regexp.escape(endtag)}[[:blank:]]*\r?(?:\n|\z)/
8585
lines = []
86-
while !scn.eos? do
86+
until scn.eos? do
8787
one_line = scn.scan_until(/(?:\n|\z)/)
8888
raise eof_error unless one_line
8989

lib/puppet/pops/types/p_object_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ def compressed_members_hash(features)
11111111
# @return [PObjectType] the topmost parent who's #equality_attributes include the given _attr_
11121112
def find_equality_definer_of(attr)
11131113
type = self
1114-
while !type.nil? do
1114+
until type.nil? do
11151115
p = type.resolved_parent
11161116
return type unless p.is_a?(PObjectType)
11171117
return type unless p.equality_attributes.include?(attr.name)

lib/puppet/scheduler/scheduler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def initialize(timer = Puppet::Scheduler::Timer.new)
88

99
def run_loop(jobs)
1010
mark_start_times(jobs, @timer.now)
11-
while not enabled(jobs).empty?
11+
until enabled(jobs).empty?
1212
@timer.wait_for(min_interval_to_next_run_from(jobs, @timer.now))
1313
run_ready(jobs, @timer.now)
1414
end

0 commit comments

Comments
 (0)