Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checkstyle : always receive File contains tab characters (this is the first instance)

I'm using Checkstyle for Java in Eclipse IDE. I don't know in every java file, at second line, I always receive warning in Checkstyle : (although I'm pretty sure that I don't press tab key)

File contains tab characters (this is the first instance).

public class Percolation {     private boolean[][] grid; ... } 

When I have typed : public class Percolation {, press enter, Eclipse will make an indent for me, after that, I type private boolean[][] grid;. But, I still receive this warning.

Please tell me how to fix this. (I don't want to turn off this warning, because this is a must. Another people will check again my file).

Thanks :)

like image 676
hqt Avatar asked Aug 30 '12 04:08

hqt


People also ask

How do you fix file contains tab characters This is the first instance?

To fix this Navigate to Preferences > Java > Code Style > Formatter. Then click on New > give name for the formatter > click on ok .


1 Answers

step 1 In eclipse, Preference > Java > Code Style > Formatter. Edit the Active profile.(If you don't wish to edit the built-in profile , create a new profile). Under "Active profile:" there is a drop down dialogue box .. beside it, click "Edit..." which opens up the edit dialog box. Under the "Indention" tab, you'll find Tab Policy. Change the Tab Policy from Mixed to Space only & apply the changes.

step 2 Back to your Eclipse Perspective, navigate via the menu bar: Source > Format Element (not "Format") and save.

Run checkstyle you won't find "File Tab Character: File contains tab characters (this is the first instance)." warning anymore.

To visualize the difference by enabling whitespace character that you'll find in tool bar.

like image 121
JToddler Avatar answered Sep 29 '22 20:09

JToddler