Brian H.
Brian H.

Reputation: 2235

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

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?

Upvotes: 23

Views: 10171

Answers (6)

Oleg Poltoratskii
Oleg Poltoratskii

Reputation: 806

Add -Djdk.util.zip.ensureTrailingSlash=false in Help | Edit Custom VM Options.

Upvotes: -1

Fangming
Fangming

Reputation: 25261

Change the default template anyway you want and then the error is gone!

enter image description here

Upvotes: 7

G00fY
G00fY

Reputation: 5297

Press Alt+Enter inside the comment and after that use rightwards-arrow on your keyboard to get a submenu where you can disable the lint check.

Upvotes: 0

Krishna V
Krishna V

Reputation: 31

Go to Settings -> File and Code Templates -> includes

Update the comment to add an extra line like below..This stays even after formatting the code.

 /**
    * Created by ${USER} 
    * on ${DATE}.
    */

Upvotes: 3

mdev
mdev

Reputation: 1416

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
 */

Upvotes: 17

Hank D
Hank D

Reputation: 6471

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".

Upvotes: 39

Related Questions