summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-08-09 12:31:44 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-08-16 18:41:25 -0700
commit7037433634d0b02574d03a8465541ea2f49d3f39 (patch)
treebb708bd38fbb6f86d0f0f01eb0b9a2da03423fd7
parent498d60207ce6664f0ca807b3f7a4690b3097014c (diff)
downloadchef-7037433634d0b02574d03a8465541ea2f49d3f39.tar.gz
autofixing Style/WhileUntilModifier cop
-rw-r--r--lib/chef/chef_fs/parallelizer/parallel_enumerable.rb8
-rw-r--r--lib/chef/resource_collection/stepable_iterator.rb4
-rw-r--r--spec/functional/run_lock_spec.rb8
-rw-r--r--spec/support/shared/functional/win32_service.rb4
-rw-r--r--spec/support/shared/integration/app_server_support.rb4
-rw-r--r--spec/unit/chef_fs/parallelizer.rb4
6 files changed, 8 insertions, 24 deletions
diff --git a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
index 9d02bbab78..ab578bdb7f 100644
--- a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
+++ b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
@@ -184,9 +184,7 @@ class Chef
sleep(0.01)
end
- until @unconsumed_output.empty?
- yield @unconsumed_output.pop
- end
+ yield @unconsumed_output.pop until @unconsumed_output.empty?
# If no one is working on our tasks and we're allowed to
# work on them in the main thread, process an input to
@@ -227,9 +225,7 @@ class Chef
def stop
@unconsumed_input.clear
- while @in_process.size > 0
- sleep(0.05)
- end
+ sleep(0.05) while @in_process.size > 0
@unconsumed_output.clear
end
diff --git a/lib/chef/resource_collection/stepable_iterator.rb b/lib/chef/resource_collection/stepable_iterator.rb
index d1165764ca..958ffa28cb 100644
--- a/lib/chef/resource_collection/stepable_iterator.rb
+++ b/lib/chef/resource_collection/stepable_iterator.rb
@@ -100,9 +100,7 @@ class Chef
end
def iterate
- while @position < size && !paused?
- step
- end
+ step while @position < size && !paused?
collection
end
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index 19d45d3e7d..998e77f6b4 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -48,9 +48,7 @@ describe Chef::RunLock do
WAIT_ON_LOCK_TIME = 1.0
def wait_on_lock
Timeout.timeout(WAIT_ON_LOCK_TIME) do
- until File.exist?(lockfile)
- sleep 0.1
- end
+ sleep 0.1 until File.exist?(lockfile)
end
rescue Timeout::Error
raise "Lockfile never created, abandoning test"
@@ -393,9 +391,7 @@ describe Chef::RunLock do
# Send it the kill signal over and over until it dies
Timeout.timeout(CLIENT_PROCESS_TIMEOUT) do
Process.kill(:KILL, pid)
- until Process.waitpid2(pid, Process::WNOHANG)
- sleep(0.05)
- end
+ sleep(0.05) until Process.waitpid2(pid, Process::WNOHANG)
end
example.log_event("#{name}.stop finished (stopped pid #{pid})")
# Process not found is perfectly fine when we're trying to kill a process :)
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index 0f9072bdef..f9cc43d3f9 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -23,9 +23,7 @@ shared_context "using Win32::Service" do
# We can only uninstall when the service is stopped.
if test_service_state != "stopped"
::Win32::Service.send("stop", "spec-service")
- while test_service_state != "stopped"
- sleep 1
- end
+ sleep 1 while test_service_state != "stopped"
end
::Win32::Service.delete("spec-service")
diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb
index 9bc48dbd93..4dfa3fa155 100644
--- a/spec/support/shared/integration/app_server_support.rb
+++ b/spec/support/shared/integration/app_server_support.rb
@@ -33,9 +33,7 @@ module AppServerSupport
end
end
Timeout.timeout(30) do
- until server && server.status == :Running
- sleep(0.01)
- end
+ sleep(0.01) until server && server.status == :Running
end
[server, thread]
end
diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb
index 9de8077677..818837fb4a 100644
--- a/spec/unit/chef_fs/parallelizer.rb
+++ b/spec/unit/chef_fs/parallelizer.rb
@@ -211,9 +211,7 @@ describe Chef::ChefFS::Parallelizer do
occupying_job_finished[0] = true
end.wait
end
- until started
- sleep(0.01)
- end
+ sleep(0.01) until started
end
after :each do