Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore hardcoded strings on logger statements-IntelliJ

On IntelliJ, I typically enable the inspection to find hard coded strings in Java projects. However, it can generate lot of false positives due to hard coded strings present in logger statements.

Is there any way in IntelliJ to ignore logger statements from this inspection ?

like image 858
codehammer Avatar asked Sep 26 '22 23:09

codehammer


1 Answers

You can annotate the String parameter of the logger method with the @NonNls annotation. The Hard coded strings inspection will then ignore the strings present in logger calls. To annotate, position the text cursor on a warning and press Alt+Enter and select Annotate parameter 'xxx' as @NonNls.

like image 170
Bas Leijdekkers Avatar answered Oct 11 '22 17:10

Bas Leijdekkers