use of com.googlecode.jslint4java.JSLint 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);
}
}
}
use of com.googlecode.jslint4java.JSLint in project jslint4java by happygiraffe.
the class JSLintTask method execute.
/**
* Scan the specified directories for JavaScript files and lint them.
*/
@Override
public void execute() throws BuildException {
if (resources.size() == 0) {
// issue 53: this isn't a fail, just a notice.
log(NO_FILES_TO_LINT);
}
JSLint lint = makeLint();
applyOptions(lint);
for (ResultFormatter rf : formatters) {
rf.begin();
}
int failedCount = 0;
int totalErrorCount = 0;
for (Resource resource : resources.listResources()) {
try {
int errorCount = lintStream(lint, resource);
if (errorCount > 0) {
totalErrorCount += errorCount;
failedCount++;
}
} catch (IOException e) {
throw new BuildException(e);
}
}
for (ResultFormatter rf : formatters) {
rf.end();
}
if (failedCount != 0) {
String msg = failureMessage(failedCount, totalErrorCount);
if (haltOnFailure) {
throw new BuildException(msg);
} else {
log(msg);
if (failureProperty != null) {
getProject().setProperty(failureProperty, msg);
}
}
}
}
Aggregations