I attended a software craftsmanship event a couple of weeks ago and one of the comments made was "I'm sure we all recognize bad code when we see it" and everyone nodded sagely without further discussion.
This sort of thing always worries me as there's that truism that everyone thinks they're an above average driver. Although I think I can recognize bad code I'd love to learn more about what other people consider to be code smells as it's rarely discussed in detail on people's blogs and only in a handful of books. In particular I think it'd be interesting to hear about anything that's a code smell in one language but not another.
I'll start off with an easy one:
Code in source control that has a high proportion of commented out code - why is it there? was it meant to be deleted? is it a half finished piece of work? maybe it shouldn't have been commented out and was only done when someone was testing something out? Personally I find this sort of thing really annoying even if it's just the odd line here and there, but when you see large blocks interspersed with the rest of the code it's totally unacceptable. It's also usually an indication that the rest of the code is likely to be of dubious quality as well.
printf("%c", 7)
typically rings alarm bells for me. ;) – Dec 13 '10 at 15:03git log -p <filename>
will give you a complete patch list for the entire history of a given file. There's probably even a built-in way to search, but I find it easiest to just pipe it through grep:git log -p <filename> | grep <needle>
. There's also the programs gitk and qgit and the website github which all have easy-to-use search interfaces for all history. – Ben Lee Feb 25 '13 at 21:09