FileHeaderCheck extends DoubleDispatchVisitorCheck { private void checkPlainText() { if (expectedLines == null) { expectedLines = headerFormat.split("(?:\r)?\n|\r"); } EsqlFile file = getContext().getEsqlFile(); List<String> lines = CheckUtils.readLines(file); if (!matches(expectedLines, lines)) { addIssue(new FileIssue(this, MESSAGE)); } }  @Override void visitProgram(ProgramTree tree); @RuleProperty(key = "headerFormat", description = "Expected copyright and license header", defaultValue = DEFAULT_HEADER_FORMAT, type = "TEXT")
	public String headerFormat; @RuleProperty(key = "isRegularExpression", description = "Whether the headerFormat is a regular expression", defaultValue = "false")
	public boolean isRegularExpression; static final Logger LOG; }
@Test public void test_plain() { EsqlCheckVerifier.issues(checkPlainText("-- copyright 2005"), file1) .noMore(); EsqlCheckVerifier.issues(checkPlainText("-- copyright 20\\d\\d"), file1) .next().atLine(null); EsqlCheckVerifier.issues(checkPlainText("-- copyright 2005"), file2) .next().atLine(null).withMessage("Add or update the header of this file."); EsqlCheckVerifier.issues(checkPlainText("-- copyright 2012"), file2) .noMore(); EsqlCheckVerifier.issues(checkPlainText("-- copyright 2012\n-- foo"), file2) .noMore(); EsqlCheckVerifier.issues(checkPlainText("-- copyright 2012\r\n-- foo"), file2) .noMore(); EsqlCheckVerifier.issues(checkPlainText("-- copyright 2012\r-- foo"), file2) .noMore(); EsqlCheckVerifier.issues(checkPlainText("-- copyright 2012\r\r-- foo"), file2) .next().atLine(null); EsqlCheckVerifier.issues(checkPlainText("-- copyright 2012\n-- foo\n\n\n\n\n\n\n\n\n\ngfoo"), file2) .next().atLine(null); EsqlCheckVerifier.issues(checkPlainText(""), new File("src/test/resources/FileHeaderCheck/file3.esql")) .noMore(); }