use of com.googlecode.jslint4java.UnicodeBomInputStream 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.UnicodeBomInputStream in project jslint4java by happygiraffe.
the class JSLintMojo method lintFile.
private JSLintResult lintFile(JSLint jsLint, File file) throws MojoExecutionException {
getLog().debug("lint " + file);
BufferedReader reader = null;
try {
UnicodeBomInputStream stream = new UnicodeBomInputStream(new FileInputStream(file));
stream.skipBOM();
reader = new BufferedReader(new InputStreamReader(stream, getEncoding()));
return jsLint.lint(file.toString(), reader);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("file not found: " + file, e);
} catch (UnsupportedEncodingException e) {
// Can never happen.
throw new MojoExecutionException("unsupported character encoding UTF-8", e);
} catch (IOException e) {
throw new MojoExecutionException("problem whilst linting " + file, e);
} finally {
Closeables.closeQuietly(reader);
}
}
Aggregations