Java annotations for commented code

Since there are probably a lot of people there, I usually comment on the code temporarily, mainly for debugging purposes. I am currently posting something like ** DEBUG ** or something that is easy to find, but I thought when I issued the compiler a warning (or even an error) whenever it finds code that is temporarily commented out may prove useful. I was thinking about using annotations, but annotations cannot be used to tag comments.

Does anyone know of a better approach than putting a string with ease of searching in the comments section of the code?

+4
source share
3 answers

At the very least, Eclipse allows you to use (and define your own) markers placed in comments that can easily be listed later. There are at least TODO and XXX, but I believe that you too can make your own.

+3
source

There are many code checking tools that can warn you about the presence of code templates that you define. most of them have built-in support for detecting common things, such as "// todo" comments left in code, etc.

most IDEs support automatic // todo detection (intellij idea, for example).

general command line tool for this checkstyle . you can run it as part of your assembly and indicate what it tells you

+4
source

If you are using Maven, consider using taglist-maven-plugin .

+1
source

Source: https://habr.com/ru/post/1489710/


All Articles