July 2013
Intermediate to advanced
370 pages
8h 27m
English
Senior developers and software architects often champion coding standards, and they try to ensure consistent practices are followed in their teams. We can use Groovy’s power to automate code review for smells and poor practices. We’ll see here how to use compile-time metaprogramming to detect smells.
Naming variables is difficult and takes effort, but using single-letter variables is morally wrong. Rather than manually policing the code, we’ll leverage compile-time metaprogramming to inspect poor variable and method names.
| AST/CodeAnalysis/smelly.groovy | |
| | def canVote(a) { |
| | a > 17 ? "You can vote" : "You can't vote" |
| | } |
| | |
| | def p(instance) { |
| | //code to print the instance... |
| | } |
The
canVote method ...
Read now
Unlock full access