Skip to content

Commit 2ffae3b

Browse files
committed
Prefer select over filter
1 parent c2be141 commit 2ffae3b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cleanup_project_files.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
checkstyle = 'style.xml,.checkstyle'
66
pmd = '.pmd,.ruleset,pmd.xml'
77

8-
files = Dir['workspace/**/.project'].filter { |file_path| file_path =~ /.*?lab0[1234567].*/ }
8+
files = Dir['workspace/**/.project'].select { |file_path| file_path =~ /.*?lab0[1234567].*/ }
99
files.each do |file_path|
1010
text = File.read(file_path)
1111
new_contents = text.gsub(regex1, '').gsub(regex2, '')
1212
puts new_contents
1313
File.write(file_path, new_contents)
1414
end
1515

16-
files_to_delete = Dir["workspace/**/{#{checkstyle},#{pmd}}"].filter { |file_path| file_path =~ /.*?lab0[1234567].*/ }
16+
files_to_delete = Dir["workspace/**/{#{checkstyle},#{pmd}}"].select { |file_path| file_path =~ /.*?lab0[1234567].*/ }
1717
files_to_delete.each do |file_path|
1818
puts "deleting #{file_path}"
1919
File.delete(file_path)

0 commit comments

Comments
 (0)