Search code examples
javaintellij-ideaannotationswarningsjavadoc

Is there a way in Java or IntelliJ 2022.2 to suppress MissingJavadoc warnings with an annotation?


I know it's possible to purposefully suppress unused method warnings in Java/IntelliJ 2022.2 by creating a custom annotation, then using the context menu to suppress the unused warning if annotated with the custom annotation. However, I would like to also do that with other warnings, especially MissingJavadoc warnings. I have some large enums in which I have purposely been very explicit concerning their names, so creating individual Javadoc comments for each element would be laborious and redundant. But, I'd rather not just use @SuppressWarnings("MissingJavadoc") if I can help it, because that loses the intentionality of making the element names explicit and just looks like sloppy coding.

Does anyone know if suppression with intentionality is possible like this for anything other than unused warnings? Or, is that all we have?


Solution

  • The javadoc tool itself is not very configurable regarding where it requires Javadoc comments to be present. For your use case, you are best off disabling javadoc's warnings and insted using a different tool to enforce that documentation is present. One such tool is require-javadoc. You could use its --dont-require=<regex> command-line argument, or you could create a version of the program with a new command-line argument that understands your naming convention.