Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix or correct the "Default File Template" warning in IntelliJ Idea

Tags:

IntelliJ Idea: 2016.1 Windows 10 Pro

When I create a new project or a new class in a new project, IntelliJ helpfully includes a default header containing my name and the date. However, it also highlights the code and displays a warning about the file using a "Default File Template". It suggests two ways to correct the code. Either by editing the template or by replacing it with an actual file template. However, neither option satisfies the warning; nor does manually replacing the contents of the header. I can't figure out a way to get rid of it.

enter image description here

I know that I can suppress the warning, but I would prefer to actually correct or fix it.

Any ideas?

like image 894
BrianHVB Avatar asked Apr 29 '16 21:04

BrianHVB


People also ask

How do I change the template in IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Editor | File and Code Templates. and specify the template name, file extension, name of the resulting file, and body of the template. Apply the changes and close the dialog.

Where are IntelliJ templates stored?

IntelliJ IDEA stores global templates in the IDE configuration directory under fileTemplates.


2 Answers

The point of it is to remind you to document your code by adding a description of the class. No matter what you set the template to, if you don't change the text that is in the template, it assumes you want a reminder to override it with some useful information. If you are not in the habit of adorning your code with informative comments, then you can disable that particular check.

To disable the check, where you see the comment block highlighted as a warning, click in that shaded area, wait for the "light bulb" intention icon to appear near the left margin, then, when it pops up a box that says "Edit template...", instead of clicking on the words, click on the little arrow to the right of the words, and select "Disable inspection".

like image 134
Hank D Avatar answered Sep 25 '22 06:09

Hank D


Just add a new line after Default Template statement which has name and date. Intellij considers that new line as part of documentation, and then stops complaining.
Update

Like this:

/**  * Created by YourName on 2017/06/11.  * THIS LINE  */ 
like image 23
mdev Avatar answered Sep 21 '22 06:09

mdev