use of com.sonarsource.checks.verifier.SingleFileVerifier in project sonar-go by SonarSource.
the class TestUtils method checkNoIssue.
public static void checkNoIssue(Check check, Path testFile, UastNode uast) throws IOException {
SingleFileVerifier verifier = analyze(check, testFile, uast);
verifier.assertNoIssues();
}
use of com.sonarsource.checks.verifier.SingleFileVerifier in project sonar-go by SonarSource.
the class TestUtils method checkRule.
public static void checkRule(Check check, Path testFile, UastNode uast) throws IOException {
SingleFileVerifier verifier = analyze(check, testFile, uast);
verifier.assertOneOrMoreIssues();
}
use of com.sonarsource.checks.verifier.SingleFileVerifier in project sonar-go by SonarSource.
the class TestUtils method analyze.
private static SingleFileVerifier analyze(Check check, Path testFile, UastNode uast) throws IOException {
TestInputFileBuilder inputFile = TestInputFileBuilder.create("test", testFile.getParent().toFile(), testFile.toFile());
inputFile.setContents(new String(Files.readAllBytes(testFile), StandardCharsets.UTF_8));
inputFile.setCharset(StandardCharsets.UTF_8);
Engine engine = new Engine(Collections.singletonList(check));
List<Issue> issues = engine.scan(uast, inputFile.build()).issues;
SingleFileVerifier verifier = SingleFileVerifier.create(testFile, StandardCharsets.UTF_8);
uast.getDescendants(UastNode.Kind.COMMENT, comment -> verifier.addComment(comment.token.line, comment.token.column, comment.token.value, 2, 0));
issues.forEach(issue -> reportIssueTo(verifier, issue));
return verifier;
}
Aggregations