From 027604c1ec14123599afc6f8e00ff7979b9ede54 Mon Sep 17 00:00:00 2001 From: Alexey Glushkov Date: Sat, 15 Oct 2011 11:29:35 +0400 Subject: [PATCH] add ruby script to check .m files on [super dealloc] calls --- DeallocCheck.rb | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 DeallocCheck.rb diff --git a/DeallocCheck.rb b/DeallocCheck.rb new file mode 100644 index 0000000..aa6c464 --- /dev/null +++ b/DeallocCheck.rb @@ -0,0 +1,73 @@ + + +scanFolder = ARGV[0] + +if(!scanFolder) + p 'waiting folder path in argument' + + exit +end + +def ScanSourceFile(filePath) + + #p filePath + + text = File.open(filePath, 'r'){ |file| file.read } + + #impArray = text.scan(/@implementation [a-zA-Z]+/) + deallocArray = text.scan(/\)[ ]*dealloc[ {]*[ \t]*$/) + superDeallocArray = text.scan(/\[[ ]*super[ ]*dealloc[ ]*\]/) + + + #p 'impArray count '+impArray.count.to_s + ' dealloc count '+deallocArray.count.to_s+' super dealloc count '+superDeallocArray.count.to_s + + if( deallocArray.count != superDeallocArray.count ) + p filePath + ' dealloc count > super dealloc count' + + p deallocArray + p superDeallocArray + end + + +=begin + impArray.each{ |item| + + item["@implementation"] = "" + item = item.delete(" ") + p item + + } +=end + + +end + +def ScanFolder(folderName) + + dirObj = Dir.new(folderName) + dirObj.each{ |fn| + + nextItem = dirObj.path + '/' + fn + + if(!File.directory?( nextItem )) + + if( fn =~ /\.m$/ ) + + ScanSourceFile(nextItem) + + end + + else + + next if(fn==".." || fn=="." || fn==".git" || fn==".svn") + + ScanFolder(nextItem) + + end + + } + +end + +ScanFolder(scanFolder) +p 'finished'