I have CheckStyle set to check for lines over 80 characters in Eclipse, and I have a margin line set up in my editor at 80 characters. If I put my cursor at the end of a line of code in my editor, the co-ordinates read (for example) 1433, 77, indicating the 77th character column from the left - yet when I run CheckStyle over the same line it says the line is 88 characters long! There are no extraneous tabs or other whitespace characters at the end of the line, it's definitely 77 long. Is CheckStyle broken?
From the Checkstyle documentation:
The calculation of the length of a line takes into account the number of expanded spaces for a tab character ('\t'). The default number of spaces is 8. To specify a different number of spaces, the user can set TreeWalker property tabWidth which applies to all Checks, including LineLength; or can set property tabWidth for LineLength alone.
http://checkstyle.sourceforge.net/config_sizes.html#LineLength
To do this in Eclipse:
TreeWalker
into the search box under Known modules.Note: in newer versions of Checkstyle setting the tab width is done via a property of LineLength
, as you can see in the config below (thanks for the hint @dropbear):
<module name="LineLength">
<property name="tabWidth" value="2"/>
</module>