Buggy code:
public class CodeFormatterVisitor extends ASTVisitor { public static class MultiFieldDeclaration extends FieldDeclaration { FieldDeclaration [ ] declarations ; MultiFieldDeclaration ( FieldDeclaration [ ] declarations ) { } } public static boolean DEBUG = false ; private static final int NO_MODIFIERS = 0 ; private static final int [ ] SINGLETYPEREFERENCE_EXPECTEDTOKENS = new int [ ] { TerminalTokens . TokenNameIdentifier , TerminalTokens . TokenNameboolean , TerminalTokens . TokenNamebyte , TerminalTokens . TokenNamechar , TerminalTokens . TokenNamedouble , TerminalTokens . TokenNamefloat , TerminalTokens . TokenNameint , TerminalTokens . TokenNamelong , TerminalTokens . TokenNameshort , TerminalTokens . TokenNamevoid } ; private static final int [ ] CLOSING_GENERICS_EXPECTEDTOKENS = new int [ ] { TerminalTokens . TokenNameRIGHT_SHIFT , TerminalTokens . TokenNameUNSIGNED_RIGHT_SHIFT , TerminalTokens . TokenNameGREATER } ; private int chunkKind ; public int lastLocalDeclarationSourceStart ; private Scanner localScanner ; public DefaultCodeFormatterOptions preferences ; public Scribe scribe ; public CodeFormatterVisitor ( DefaultCodeFormatterOptions preferences , Map settings , int offset , int length , CodeSnippetParsingUtil codeSnippetParsingUtil ) { } public void acceptProblem ( IProblem problem ) { } private BinaryExpressionFragmentBuilder buildFragments ( BinaryExpression binaryExpression , BlockScope scope ) { } private CascadingMethodInvocationFragmentBuilder buildFragments ( MessageSend messageSend , BlockScope scope ) { } public boolean checkChunkStart ( int kind ) { } private boolean commentStartsBlock ( int start , int end ) { } private ASTNode [ ] computeMergedMemberDeclarations ( ASTNode [ ] nodes ) { } private ASTNode [ ] computeMergedMemberDeclarations ( TypeDeclaration typeDeclaration ) { } private boolean dumpBinaryExpression ( BinaryExpression binaryExpression , int operator , BlockScope scope ) { } private boolean dumpEqualityExpression ( BinaryExpression binaryExpression , int operator , BlockScope scope ) { } private final TextEdit failedToFormat ( ) { } private void format ( AbstractMethodDeclaration methodDeclaration , ClassScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { } private void format ( FieldDeclaration fieldDeclaration , ASTVisitor visitor , MethodScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { } private void format ( CodeFormatterVisitor . MultiFieldDeclaration multiFieldDeclaration , ASTVisitor visitor , MethodScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { } public TextEdit format ( String string , ASTNode [ ] nodes ) { } public TextEdit format ( String string , CompilationUnitDeclaration compilationUnitDeclaration ) { } public TextEdit format ( String string , ConstructorDeclaration constructorDeclaration ) { } public TextEdit format ( String string , Expression expression ) { } public TextEdit format ( String string , CommentRegion region ) { } private void format ( TypeDeclaration typeDeclaration ) { } private void format ( TypeDeclaration memberTypeDeclaration , ClassScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { } private void formatAnonymousTypeDeclaration ( TypeDeclaration typeDeclaration ) { } private void formatBlock ( Block block , BlockScope scope , String block_brace_position , boolean insertSpaceBeforeOpeningBrace ) { } private void formatCascadingMessageSends ( CascadingMethodInvocationFragmentBuilder builder , BlockScope scope ) { } private void formatClassBodyDeclarations ( ASTNode [ ] nodes ) { } private void formatEmptyTypeDeclaration ( boolean isFirst ) { } private void formatGuardClauseBlock ( Block block , BlockScope scope ) { } private void formatLeftCurlyBrace ( final int line , final String bracePosition ) { } private void formatLocalDeclaration ( LocalDeclaration localDeclaration , BlockScope scope , boolean insertSpaceBeforeComma , boolean insertSpaceAfterComma ) { } private void formatMessageSend ( MessageSend messageSend , BlockScope scope , Alignment messageAlignment ) { } private void formatMethodArguments ( AbstractMethodDeclaration methodDeclaration , boolean spaceBeforeOpenParen , boolean spaceBetweenEmptyParameters , boolean spaceBeforeClosingParen , boolean spaceBeforeFirstParameter , boolean spaceBeforeComma , boolean spaceAfterComma , int methodDeclarationParametersAlignment ) { } private void formatEnumConstantArguments ( FieldDeclaration enumConstant , boolean spaceBeforeOpenParen , boolean spaceBetweenEmptyParameters , boolean spaceBeforeClosingParen , boolean spaceBeforeFirstParameter , boolean spaceBeforeComma , boolean spaceAfterComma , int methodDeclarationParametersAlignment ) { } private void formatNecessaryEmptyStatement ( ) { } private void formatOpeningBrace ( String bracePosition , boolean insertSpaceBeforeBrace ) { } private void formatStatements ( BlockScope scope , final Statement [ ] statements , boolean insertNewLineAfterLastStatement ) { } private void formatThrowsClause ( AbstractMethodDeclaration methodDeclaration , boolean spaceBeforeComma , boolean spaceAfterComma , int alignmentForThrowsClause ) { } private void formatTypeMembers ( TypeDeclaration typeDeclaration ) { } private void formatTypeOpeningBraceForEnumConstant ( String bracePosition , boolean insertSpaceBeforeBrace , TypeDeclaration typeDeclaration ) { } private void formatTypeOpeningBrace ( String bracePosition , boolean insertSpaceBeforeBrace , TypeDeclaration typeDeclaration ) { int fieldCount = ( ( typeDeclaration . fields ) == null ) ? 0 : typeDeclaration . fields . length ; int methodCount = ( ( typeDeclaration . methods ) == null ) ? 0 : typeDeclaration . methods . length ; int typeCount = ( ( typeDeclaration . memberTypes ) == null ) ? 0 : typeDeclaration . memberTypes . length ; <START_BUG> if ( methodCount != 0 ) { <END_BUG> for ( int i = 0 , max = methodCount ; i < max ; i ++ ) { final AbstractMethodDeclaration abstractMethodDeclaration = typeDeclaration . methods [ i ] ; if ( abstractMethodDeclaration . isDefaultConstructor ( ) ) { methodCount -- ; } else if ( abstractMethodDeclaration . isClinit ( ) ) { methodCount -- ; } } } final int memberLength = ( fieldCount + methodCount ) + typeCount ; boolean insertNewLine = memberLength > 0 ; if ( ! insertNewLine ) { if ( ( TypeDeclaration . kind ( typeDeclaration . modifiers ) ) == ( TypeDeclaration . ENUM_DECL ) ) { insertNewLine = this . preferences . insert_new_line_in_empty_enum_declaration ; } else if ( ( ( typeDeclaration . bits ) & ( ASTNode . IsAnonymousType ) ) != 0 ) { insertNewLine = this . preferences . insert_new_line_in_empty_anonymous_type_declaration ; } else { insertNewLine = this . preferences . insert_new_line_in_empty_type_declaration ; } } formatOpeningBrace ( bracePosition , insertSpaceBeforeBrace ) ; if ( insertNewLine ) { this . scribe . printNewLine ( ) ; } } private int getDimensions ( ) { } private boolean hasComments ( ) { } private boolean isNextToken ( int tokenName ) { } private boolean isClosingGenericToken ( ) { } private boolean isGuardClause ( Block block ) { } private boolean isMultipleLocalDeclaration ( LocalDeclaration localDeclaration ) { }

Fix:
if ( methodCount <= 2 ) {