Since Checkstyle 5.0
'\t'
) in the source code.
Rationale:
To configure the check to report only the first instance in each file:
<module name="Checker"> <module name="FileTabCharacter"/> </module>
Example - Test.java:
class Example1 { int a; // violation 'File contains tab characters' public void foo (int arg) { // OK, only first occurrence in file reported a = arg; // OK, indented using spaces } }
To configure the check to report each instance in each file:
<module name="Checker"> <module name="FileTabCharacter"> <property name="eachLine" value="true"/> </module> </module>
Example - Test.java:
class Example2 { int a; // violation 'contains a tab character' public void foo (int arg) { // violation 'contains a tab character' a = arg; // OK, indented using spaces } }
To configure the check to report instances on only certain file types:
<module name="Checker"> <module name="FileTabCharacter"> <property name="fileExtensions" value="java, xml"/> </module> </module>
Example - Test.java:
class Example3 { int a; // violation 'File contains tab characters' public void foo (int arg) { // OK, only first occurrence in file reported a = arg; // OK, indented using spaces } }
Example - Test.xml:
<?xml version="1.0" encoding="UTF-8" ?> <UserAccount> <FirstName>John</FirstName> // violation 'File contains tab characters' <LastName>Doe</LastName> <!-- OK, only first occurrence in file reported --> </UserAccount>
Example - Test.html:
<head> <title>Page Title</title> <!-- OK, no check performed on html file extension --> </head> <!-- not specified in check config --> <body> <p>This is a simple html document.</p> </body>
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.whitespace