Search in sources :

Example 1 with JSLint

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);
        }
    }
}
Also used : JSLint(com.googlecode.jslint4java.JSLint) MojoFailureException(org.apache.maven.plugin.MojoFailureException) JSLintResult(com.googlecode.jslint4java.JSLintResult) File(java.io.File) JSLint(com.googlecode.jslint4java.JSLint)

Example 2 with JSLint

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);
            }
        }
    }
}
Also used : JSLint(com.googlecode.jslint4java.JSLint) Resource(org.apache.tools.ant.types.Resource) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) JSLint(com.googlecode.jslint4java.JSLint)

Aggregations

JSLint (com.googlecode.jslint4java.JSLint)2 JSLintResult (com.googlecode.jslint4java.JSLintResult)1 File (java.io.File)1 IOException (java.io.IOException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 BuildException (org.apache.tools.ant.BuildException)1 Resource (org.apache.tools.ant.types.Resource)1