[Adium-devl] Static analysis in buildbot

Peter Hosey prh at boredzo.org
Wed Jul 9 06:38:24 UTC 2008


On Jul 08, 2008, at 15:42:15, Christopher Forsythe wrote:
> Maybe something that actually printed the method called, and if that  
> changes then diff it? Print something a bit more than a line number  
> so that you can have more to compare against when changes do occur?

I'm not sure what exactly you meant here, but it gave me an idea:  
Record each bug as a sequence of the lines involved, without any of  
the lines not involved.

For example, this bug:

	http://rgov.org/adium/r24211/report-1wq6NX.html#EndPath

becomes:

0 - (NSArray *)generateXMLFromDirectory:(NSString *)basePath
1 	while (file = [enumerator nextObject]) #TRUE
2 		if (!exists) #FALSE
3 		if ([file hasPrefix:@".DS_Store"]) #FALSE
4 		if (directory) #TRUE
5 			if (posixFlags != nil) #FALSE
6 			while (child = [dirEnumerator nextObject]) #FALSE
7 	while (file = [enumerator nextObject]) #TRUE
8 		if (!exists) #FALSE
9 		if ([file hasPrefix:@".DS_Store"]) #FALSE
10 		if (directory) #TRUE
11 			if (posixFlags != nil) #FALSE
12 			while (child = [dirEnumerator nextObject]) #FALSE
13 	while (file = [enumerator nextObject]) #TRUE
14 		if (!exists) #FALSE
15 		if ([file hasPrefix:@".DS_Store"]) #FALSE
16 		if (directory) #FALSE
17 			if (mimeType != nil) #FALSE
18 			if (posixFlags != nil) #FALSE
19 			if (size != nil) #FALSE
20 			NSXMLElement *name = [[NSXMLElement alloc] initWithName:@"name"  
stringValue:file];
21 			[fileXML addChild:name];

Advantages and other notes:

1. This *will* uniquely refer to any particular leak.
2. You could hash this sequence to get a shorter identifier (e.g., for  
the URL).
3. If any expression changes, then it may change the bug, too, so it's  
probably worth assigning a new identifier. (You could, perhaps, refine  
this by excluding most of the false expressions.)
4. Whitespace is not taken from the original file, since some people  
use spaces or use tabs incorrectly. Every statement is one line, and  
every tab indicates one level of scope.





More information about the devel mailing list