Skip to content

Commit

Permalink
(#18494) Rearrange loop to remove Ruby 2.0 warning
Browse files Browse the repository at this point in the history
Ruby 2.0 warned of the complex assignments in the while loop:

  lib/puppet/file_serving/fileset.rb:139: warning: found = in conditional, should be ==

The block that shifts to the next recursion level has been removed from the
loop expression to prevent the interpreter from warning.
  • Loading branch information
Dominic Cleal authored and Jeff McCune committed Feb 11, 2013
1 parent 7ac8582 commit c2295b7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/puppet/file_serving/fileset.rb
Expand Up @@ -136,7 +136,7 @@ def perform_recursion
result = []
return result unless recurse?(depth)

while dir_path = current_dirs.shift or ((depth += 1) and recurse?(depth) and current_dirs = next_dirs and next_dirs = [] and dir_path = current_dirs.shift)
while dir_path = current_dirs.shift
next unless stat = stat(dir_path)
next unless stat.directory?

Expand All @@ -153,6 +153,14 @@ def perform_recursion
# And to our list of files/directories to iterate over.
next_dirs << File.join(dir_path, file_path)
end

# Move to the next recusion level
if current_dirs.empty?
depth += 1
break unless recurse?(depth)
current_dirs = next_dirs
next_dirs = []
end

This comment has been minimized.

Copy link
@Sharpie

Sharpie Apr 22, 2013

Member

This check will never get exercised if current_path contains no directories as the next statements on lines 140 and 141 will keep skipping to the next iteration.

end

result
Expand Down

0 comments on commit c2295b7

Please sign in to comment.