From b31eac56097a0bfc5f5af70de91ad261067a395f Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Mon, 30 Jan 2012 00:54:17 +0800 Subject: Replaced all 'for' loops with Enumerable#each --- activerecord/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/Rakefile') diff --git a/activerecord/Rakefile b/activerecord/Rakefile index d769a73dba..e7d74b4f3e 100755 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -187,7 +187,7 @@ end task :lines do lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 - for file_name in FileList["lib/active_record/**/*.rb"] + FileList["lib/active_record/**/*.rb"].each do |file_name| next if file_name =~ /vendor/ f = File.open(file_name) -- cgit v1.2.3 From bf928bc7329640969917eb680da4de959b7156b7 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Mon, 30 Jan 2012 01:27:43 +0800 Subject: Use block form of 'File.open' so that File object is auto closed at end --- activerecord/Rakefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'activerecord/Rakefile') diff --git a/activerecord/Rakefile b/activerecord/Rakefile index e7d74b4f3e..98020ad3ab 100755 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -189,13 +189,13 @@ task :lines do FileList["lib/active_record/**/*.rb"].each do |file_name| next if file_name =~ /vendor/ - f = File.open(file_name) - - while line = f.gets - lines += 1 - next if line =~ /^\s*$/ - next if line =~ /^\s*#/ - codelines += 1 + File.open(file_name, 'r') do |f| + while line = f.gets + lines += 1 + next if line =~ /^\s*$/ + next if line =~ /^\s*#/ + codelines += 1 + end end puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}" -- cgit v1.2.3