SmallLint is a famous code critics tool for Smalltalk that checks for over 60 common types of code smell and possible bugs. I’ve added a couple of rules that are targeted at Seaside applications:
- Avoid unnecessary #with:
Sending #with: is only required if attributes are specified.
- Extract callback code to separate method
For clarity rendering code and callback code should not be mixed, extract the contents of the callback block to a separate method.
- Unnecessary block passed to brush
Sending a block as argument to #with: is only needed when nesting brushes.
- #with: has to be last message in cascade
Sending #with: triggers serialization of the brush attributes, any attribute being specified afterwards has no effect.
- #call:/#answer: while rendering
#call: and #answer: should only be used from callback code, not within the rendering code.
- Changes state while rendering
Application state should not be changed in the rendering code, use a callback to change state.
- Does not send super to hook method
Always send super when overriding hook methods like #updateRoot:, #updateUrl:, #initialRequest:, ...
- Sends deprecated message
Deprecated methods will all be removed with the next version of Seaside.
To try these rules on your own code, load the package
http://source.lukas-renggli.ch/slime/. It takes a while to load the first time, as the tool builds up some caches on valid brush names. As a prerequisite the Refactoring Engine is required.
The rules are not bulletproof and by no means complete. It could well be that you encounter false positives or that it misses some serious problems, but it should give you an idea where your code might need some refactoring. If anybody has particular ideas on what could be checked additionally, I am glad to include more rules.