Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java annotation for commented out code

So like probably many people out there I usually comment out code temporarily, mostly for debugging purposes. I currently put something like **DEBUG** or whatever that is easily searched for, but I thought having the compiler output a warning (or even an error) whenever it finds code that is temporarily commented out could be useful. I thought of using an annotation, but annotations can't be used to mark comments.

Does anyone know of a better approach than putting an easily searchable string in the commented-out section of code?

like image 833
deinocheirus Avatar asked Feb 16 '23 00:02

deinocheirus


1 Answers

there are plenty of code inspection tools out there that can alert you to the presence of code patterns that you define. most of them have built-in support for detecting common stuff like "//todo" comments left in code etc.

most IDEs support auto-detection of //todo as well (intellij idea, for example).

a common command-line tool for this is checkstyle. you could run it as part of your build and have it point these things out to you

like image 166
radai Avatar answered Feb 27 '23 09:02

radai