lintal fix
Automatic fixes
lintal can automatically fix many checkstyle violations that would otherwise require manual editing. Every fix is validated against checkstyle's own test suite and compiled with javac to guarantee correctness.
$
Fix in place
$
Preview changes
$
Include unsafe fixes
$
Whitespace
Spacing and indentation
Fix operator spacing, indentation levels, extra spaces, and line wrapping rules automatically.
WhitespaceAround
Add required whitespace around operators and keywordsIndentation
Correct indentation to configured level (default: 4 spaces)SingleSpaceSeparator
Collapse multiple spaces to a single spaceNoWhitespaceBefore
Remove whitespace before semicolons, commas, and postfix operatorsOperatorWrap
Move operators to end of line (eol) or beginning of next line (nl)EmptyLineSeparator
Add required blank lines between class membersBlocks
Brace placement
Enforce consistent placement of opening and closing curly braces across your codebase.
LeftCurly
Move opening braces to end of line (eol) or new line (nl)RightCurly
Place closing brace on same line as else/catch/finallyModifiers
Modifier ordering and correctness
Reorder modifiers to the canonical JLS order, add final where required, and remove redundant modifiers.
ModifierOrder
Reorder modifiers to the canonical Java Language Specification orderRedundantModifier
Remove redundant modifiers from interface membersFinalParameters
Add final to method and constructor parametersFinalLocalVariable
Add final to local variables that are never reassignedFinalClass
Add final to classes with only private constructorsImports
Import cleanup
Remove unused and redundant imports to keep your file headers clean.
UnusedImports
Remove import statements that are not referenced in the fileRedundantImport
Remove duplicate imports and unnecessary java.lang importsStyle & Coding
Code style consistency
Enforce consistent array declarations, long literal suffixes, and one-statement-per-line.
ArrayTypeStyle
Convert C-style array declarations to Java-styleUpperEll
Replace lowercase 'l' with uppercase 'L' in long literalsOneStatementPerLine
Split multiple statements on the same lineMiscellaneous
File-level fixes
Fix file-level issues like missing trailing newlines automatically.
NewlineAtEndOfFile
Add missing newline at end of fileUnsafe Fixes
Semantic transformations
These fixes change the semantics of your code and require the
--unsafe-fixes flag. Always review the changes before committing.StringLiteralEquality
Replace == with .equals() for string comparisonsSimplifyBooleanExpression
Simplify redundant boolean comparisons and ternariesEmptyStatement
Remove stray semicolons (empty statements)MissingJavadocMethod
Add placeholder Javadoc stubs to public methodsReady to automate your Java formatting?
Run lintal fix src/ and let lintal handle the tedious formatting work for you.