se.vandmo.textchecker.maven.rules.NoWhitespaceOnBlankLines Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of text-checker-maven-plugin Show documentation
Show all versions of text-checker-maven-plugin Show documentation
Maven plugin that checks that text files adheres to certain rules.
package se.vandmo.textchecker.maven.rules;
import static com.google.common.collect.Lists.newArrayList;
import static java.util.Collections.emptyList;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.Collection;
import se.vandmo.textchecker.maven.Complaint;
import se.vandmo.textchecker.maven.Content;
import se.vandmo.textchecker.maven.Rule;
import se.vandmo.textchecker.maven.annotations.FixWith;
import se.vandmo.textchecker.maven.fixers.RemoveWhitespaceOnBlankLines;
@FixWith(RemoveWhitespaceOnBlankLines.class)
public final class NoWhitespaceOnBlankLines implements Rule {
@Override
public Collection check(Content content) {
if (!content.checkLines(NoWhitespaceOnBlankLines::isOk)) {
return newArrayList(new Complaint("File contains whitespace on blank line"));
}
return emptyList();
}
public static boolean isOk(String line) {
return isNotBlank(line) || line.length() == 0;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy