diff --git a/build.gradle b/build.gradle index 9bdafe4..7853434 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ targetCompatibility = '1.6' defaultTasks 'clean', 'build' -version = '1.4.1' +version = '1.4.1-SNAPSHOT' group = 'com.eriwen' ext.archivesBaseName = 'gradle-js-plugin' ext.isSnapshot = version.endsWith("-SNAPSHOT") diff --git a/src/main/resources/jshint-rhino-r12.js b/src/main/resources/jshint-rhino-r12.js index 88c53d9..4da9f52 100755 --- a/src/main/resources/jshint-rhino-r12.js +++ b/src/main/resources/jshint-rhino-r12.js @@ -4834,6 +4834,142 @@ if (typeof exports === "object" && exports) { /*jshint boss: true, rhino: true, unused: true, undef: true, white: true, quotmark: double */ /*global JSHINT*/ + +// Author: Boy Baukema +// http://github.com/relaxnow +var checkstyleReporter = +{ + reporter: function (results, data) + { + "use strict"; + + var files = {}, + out = [], + pairs = { + "&": "&", + '"': """, + "'": "'", + "<": "<", + ">": ">" + }, + file, fileName, i, issue, globals, unuseds; + + function encode(s) { + for (var r in pairs) { + if (typeof(s) !== "undefined") { + s = s.replace(new RegExp(r, "g"), pairs[r]); + } + } + return s || ""; + } + + results.forEach(function (result) { + // Register the file + result.file = result.file.replace(/^\.\//, ''); + if (!files[result.file]) { + files[result.file] = []; + } + + // Add the error + files[result.file].push({ + severity: 'error', + line: result.error.line, + column: result.error.character, + message: result.error.reason, + source: result.error.raw + }); + }); + + data.forEach(function (result) { + file = data.file; + globals = result.implieds; + unuseds = result.unused; + + // Register the file + result.file = result.file.replace(/^\.\//, ''); + if (!files[result.file]) { + files[result.file] = []; + } + + if (globals) { + globals.forEach(function (global) { + files[result.file].push({ + severity: 'warning', + line: global.line, + column: 0, + message: "Implied global '" + global.name + "'", + source: 'jshint.implied-globals' + }); + }); + } + if (unuseds) { + unuseds.forEach(function (unused) { + files[result.file].push({ + severity: 'warning', + line: unused.line, + column: 0, + message: "Unused variable: '" + unused.name + "'", + source: 'jshint.implied-unuseds' + }); + }); + } + }); + + out.push(""); + out.push(""); + + for (fileName in files) { + if (files.hasOwnProperty(fileName)) { + out.push("\t"); + for (i = 0; i < files[fileName].length; i++) { + issue = files[fileName][i]; + out.push( + "\t\t" + ); + } + out.push("\t"); + } + } + + out.push(""); + + if (typeof process !== "undefined") { + process.stdout.write(out.join("\n") + "\n"); + } else { + print(out.join("\n") + "\n"); + } + } +}; + +var reportWithReporter = function (reporter, file) { + var results = []; + var data = []; + var lintData; + + JSHINT.errors.forEach(function (err) { + if (err) { + results.push({ file: file, error: err }); + } + }); + + lintData = JSHINT.data(); + if (lintData) { + lintData.file = file; + data.push(lintData); + } + + if (reporter) { + reporter(results, data, { verbose: true}); + } + +}; + (function (args) { var filenames = []; var optstr; // arg1=val1,arg2=val2,... @@ -4841,6 +4977,8 @@ if (typeof exports === "object" && exports) { var opts = {}; var retval = 0; + print("Calling rhino with: " + args.join(", ")); + args.forEach(function (arg) { if (arg.indexOf("=") > -1) { if (!optstr) { @@ -4904,12 +5042,17 @@ if (typeof exports === "object" && exports) { } if (!JSHINT(input, opts)) { + if (checkstyleReporter) { + reportWithReporter(checkstyleReporter.reporter, name); + } + else { for (var i = 0, err; err = JSHINT.errors[i]; i += 1) { print(err.reason + " (" + name + ":" + err.line + ":" + err.character + ")"); print("> " + (err.evidence || "").replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); print(""); } - retval = 1; + } + retval = 1; } });