Stats on class comments in 3.7alpha-5764!

goran.krampe at bluefish.se goran.krampe at bluefish.se
Wed Mar 3 10:09:24 UTC 2004


Hi people!

Regarding the current discussion on style and comments I decided to
spice up the code I once hacked on:
http://minnow.cc.gatech.edu/squeak/804

The resulting FAT do-it is below. It will print three lists on
Transcript showing the horrific truth regarding our class comments. :)

And yes - this made me discover that even *I* (gasp) have missing class
comments in SMBase and SMLoader. Shit! :) Rest assured I will take care
of that little accident.

Note that category stats are grouped by category name up to first
hyphen, which does make it slightly strange at times.

"enjoy", Göran
--------

| categoryPatterns uglies goodies prefix extractBlock printBlock
listBlock |
uglies _ Dictionary new.
goodies _ Dictionary new.
categoryPatterns := #('*').
categoryPatterns do: [:pat |
	(SystemOrganization categoriesMatching: pat) do: [:cat |
		prefix _ (cat findTokens: '-') first.
		(SystemOrganization superclassOrder: cat) do: [:c |
			uglies at: prefix ifAbsent: [uglies at: prefix put: OrderedCollection
new.
				goodies at: prefix put: OrderedCollection new].
			selected _ c theNonMetaClass organization classComment isEmpty
				ifTrue:[uglies] ifFalse: [goodies].
			(selected at: prefix) add: c name]]].
extractBlock _ [:c | | good bad|
	good _ (goodies at: c) size.
	bad _ (uglies at: c) size.
	{ c.  bad. bad+good.  ((bad / (good+bad)) asFloat * 100) truncated}].
printBlock _ [:c :bad :total :percent | 
		Transcript nextPutAll: c; nextPutAll: ': ';nextPutAll: bad
printString;
			nextPutAll: ' (',total printString , ') ',percent printString, '%';
cr].
listBlock _ [:sortBlock |
	((uglies keys collect: [:c | extractBlock value: c])
asOrderedCollection sortBy: sortBlock)
		do: [:values |
			values second > 0 ifTrue: [
			printBlock value: values first value: values second value: values
third value: values fourth]]].

Transcript clear; nextPutAll: 'Packages (category prefix) sorted by
bad';cr.
listBlock value: [:a :b | a second > b second]. "Sort by number of bads"

Transcript cr; nextPutAll: 'Packages (category prefix) sorted
alphabetically:';cr.
listBlock value: [:a :b | a first < b first].  "Sort by category prefix"

Transcript cr; nextPutAll: 'Packages (category prefix) sorted by
percents bad';cr.
listBlock value: [:a :b | a last > b last].  "Sort by percent"
Transcript flush



More information about the Squeak-dev mailing list