use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class Main method lintFile.
// Eclipse's static analysis thinks I never close the UnicodeBomInputStream below.
private void lintFile(String file) throws IOException {
BufferedReader reader = null;
try {
reader = readerForFile(file);
JSLintResult result = lint.lint(file, reader);
String msg = formatter.format(result);
if (msg.length() > 0) {
info(msg);
}
if (!result.getIssues().isEmpty()) {
setErrored(true);
}
} catch (FileNotFoundException e) {
die(file + ": No such file or directory.");
} finally {
if (reader != null) {
reader.close();
}
}
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class CheckstyleXmlFormatterTest method shouldHaveNoProblems.
@Test
public void shouldHaveNoProblems() throws Exception {
JSLintResult result = new JSLintResult.ResultBuilder("hello.js").duration(0).build();
String expected = "<file name=\"hello.js\" />";
XMLAssert.assertXMLEqual(expected, form.format(result));
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class CheckstyleXmlFormatterTest method shouldHaveOneProblem.
@Test
public void shouldHaveOneProblem() throws Exception {
String name = "bad.js";
Issue issue = new Issue.IssueBuilder(name, 1, 1, "this is not a daffodil").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).addIssue(issue).build();
String expected = "<file name=\"bad.js\">" + "<error line='1' column='1' severity='warning' message='this is not a daffodil'" + " source='com.googlecode.jslint4java.JSLint' />" + "</file>";
XMLAssert.assertXMLEqual(expected, form.format(result));
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class JSLintXmlFormatterTest method testNoOutput.
@Test
public void testNoOutput() throws Exception {
JSLintResult result = new JSLintResult.ResultBuilder("good.js").build();
String expected = "<file name='good.js'/>";
String actual = form.format(result);
XMLAssert.assertXMLEqual(expected, actual);
XMLAssert.assertXMLValid(getValidatorFor(actual));
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class JSLintXmlFormatterTest method testOneIssue.
@Test
public void testOneIssue() throws Exception {
String name = "bad.js";
Issue issue = new Issue.IssueBuilder(name, 1, 1, "too many goats teleported").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).addIssue(issue).build();
String expected = "<file name='bad.js'>" + "<issue line='1' char='1' reason='too many goats teleported' evidence='' />" + "</file>";
String actual = form.format(result);
XMLAssert.assertXMLEqual(expected, actual);
XMLAssert.assertXMLValid(getValidatorFor(actual));
}
Aggregations