--- a/Tools_ClassChecker.st Wed May 12 18:44:16 2010 +0200
+++ b/Tools_ClassChecker.st Tue May 18 15:15:54 2010 +0200
@@ -125,8 +125,12 @@
styleChecks
self doCheck:#checkProtocols.
self doCheck:#sendsObsoleteMethodWarningButNotTaggedAsObsoleteOrViceVersa.
+ self doCheck:#unusedInstanceVariables.
+ self doCheck:#unusedClassVariables.
"/ self doCheck:#guardingClause.
+
+ "Modified: / 18-05-2010 / 14:38:15 / cg"
!
warningChecks
@@ -517,6 +521,64 @@
]
]
].
+!
+
+unusedClassVariables
+ |remainingVars|
+
+ remainingVars := checkedClass theNonMetaclass classVarNames asSet.
+
+ checkedClass theNonMetaclass withAllSubclassesDo:[:eachClassToCheck |
+ eachClassToCheck instAndClassMethodsDo:[:method |
+ |source parser|
+
+ source := method source.
+ parser := Parser
+ parseMethod:source
+ in:eachClassToCheck
+ ignoreErrors:true
+ ignoreWarnings:true.
+
+ (parser notNil and:[parser ~~ #Error]) ifTrue:[
+ remainingVars removeAllFoundIn:(parser usedClassVars)
+ ].
+ ].
+ ].
+
+ remainingVars asSortedCollection do:[:eachVar |
+ self rememberBadClass:checkedClass info:'Unused class variable: ',eachVar
+ ].
+
+ "Created: / 18-05-2010 / 14:37:42 / cg"
+!
+
+unusedInstanceVariables
+ |remainingVars|
+
+ remainingVars := checkedClass theNonMetaclass instVarNames asSet.
+
+ checkedClass theNonMetaclass withAllSubclassesDo:[:eachClassToCheck |
+ eachClassToCheck methodDictionary keysAndValuesDo:[:mSelector :method |
+ |source parser|
+
+ source := method source.
+ parser := Parser
+ parseMethod:source
+ in:eachClassToCheck
+ ignoreErrors:true
+ ignoreWarnings:true.
+
+ (parser notNil and:[parser ~~ #Error]) ifTrue:[
+ remainingVars removeAllFoundIn:(parser usedInstVars)
+ ].
+ ].
+ ].
+
+ remainingVars asSortedCollection do:[:eachVar |
+ self rememberBadClass:checkedClass info:'Unused instance variable: ',eachVar
+ ].
+
+ "Created: / 18-05-2010 / 14:32:09 / cg"
! !
!ClassChecker methodsFor:'helpers'!
@@ -847,9 +909,9 @@
!ClassChecker class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/Tools_ClassChecker.st,v 1.14 2009-11-12 16:25:59 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Tools_ClassChecker.st,v 1.15 2010-05-18 13:15:54 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/Tools_ClassChecker.st,v 1.14 2009-11-12 16:25:59 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Tools_ClassChecker.st,v 1.15 2010-05-18 13:15:54 cg Exp $'
! !