Created
October 26, 2016 09:18
-
-
Save leeym/4047692b80e30cd33dc58071034438c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.wealthfront.test.filesetcheck; | |
import java.io.File; | |
import java.util.List; | |
import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; | |
import com.puppycrawl.tools.checkstyle.api.CheckstyleException; | |
import com.puppycrawl.tools.checkstyle.api.FileContents; | |
import com.puppycrawl.tools.checkstyle.api.FileText; | |
public class MultipleEmptyLinesFileSetCheck extends AbstractFileSetCheck { | |
@Override | |
protected void processFiltered(File file, List<String> lines) throws CheckstyleException { | |
if (file.getPath().endsWith(".java")) { | |
final int countLessOne = lines.size() - 1; | |
final FileContents contents = new FileContents(FileText.fromLines(file, lines)); | |
for (int lineNumber = 0; lineNumber < countLessOne; lineNumber++) { | |
if (contents.lineIsBlank(lineNumber) && contents.lineIsBlank(lineNumber+1)) { | |
log(lineNumber+2, "Multiple empty lines."); | |
while (lineNumber < countLessOne && contents.lineIsBlank(lineNumber)) { | |
lineNumber++; | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment