use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class JUnitXmlResultFormatterTest method testFileSetReallyIsFile.
@Test
public void testFileSetReallyIsFile() throws Exception {
thrown.expect(BuildException.class);
thrown.expectMessage("must be a directory");
JSLintResult result = aResult("foo.js");
formatter.setFile(folder.newFile("foo"));
formatResult(result);
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class XmlResultFormatterTest method testXmlOutputGood.
@Test
public void testXmlOutputGood() throws Exception {
JSLintResult result = new JSLintResult.ResultBuilder("main.js").build();
runTest(result);
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class JSLintTask method lintStream.
/**
* Lint a given stream. Closes the stream after use.
*
* @param lint
*
* @throws IOException
*/
private int lintStream(JSLint lint, Resource resource) throws UnsupportedEncodingException, IOException {
BufferedReader reader = null;
try {
UnicodeBomInputStream stream = new UnicodeBomInputStream(resource.getInputStream());
stream.skipBOM();
reader = new BufferedReader(new InputStreamReader(stream, encoding));
String name = resource.toString();
JSLintResult result = lint.lint(name, reader);
log("Found " + result.getIssues().size() + " issues in " + name, Project.MSG_VERBOSE);
for (ResultFormatter rf : formatters) {
rf.output(result);
}
return result.getIssues().size();
} finally {
if (reader != null) {
reader.close();
}
}
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class XmlResultFormatterTest method testXmlOutputBad.
@Test
public void testXmlOutputBad() throws Exception {
String name = "main.js";
Issue issue = new Issue.IssueBuilder(name, 1, 1, "smelly socks").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).addIssue(issue).build();
runTest(result);
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class JSLintMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("skipping JSLint");
return;
}
JSLint jsLint = applyJSlintSource();
applyDefaults();
applyOptions(jsLint);
List<File> files = getFilesToProcess();
int failures = 0;
ReportWriter reporter = makeReportWriter();
try {
reporter.open();
for (File file : files) {
JSLintResult result = lintFile(jsLint, file);
failures += result.getIssues().size();
logIssues(result, reporter);
}
} finally {
reporter.close();
}
if (failures > 0) {
String message = "JSLint found " + failures + " problems in " + files.size() + " files";
if (failOnError) {
throw new MojoFailureException(message);
} else {
getLog().info(message);
}
}
}
Aggregations