JsHintResult result = rhinoHandle.process(spec);
setDidWork(true);
// TODO - this is all terribly lame. We need some proper reporting here (which means implementing Reporting).
Logger logger = getLogger();
boolean anyErrors = false;
Map<String, Map<?, ?>> reportData = new LinkedHashMap<String, Map<?, ?>>(result.getResults().size());
for (Map.Entry<File, Map<String, Object>> fileEntry: result.getResults().entrySet()) {
File file = fileEntry.getKey();
Map<String, Object> data = fileEntry.getValue();
reportData.put(file.getAbsolutePath(), data);
if (data.containsKey("errors")) {
anyErrors = true;
URI projectDirUri = getProject().getProjectDir().toURI();
@SuppressWarnings("unchecked") Map<String, Object> errors = (Map<String, Object>) data.get("errors");
if (!errors.isEmpty()) {
URI relativePath = projectDirUri.relativize(file.toURI());
logger.warn("JsHint errors for file: {}", relativePath.getPath());
for (Map.Entry<String, Object> errorEntry : errors.entrySet()) {
@SuppressWarnings("unchecked") Map<String, Object> error = (Map<String, Object>) errorEntry.getValue();
int line = Float.valueOf(error.get("line").toString()).intValue();
int character = Float.valueOf(error.get("character").toString()).intValue();
String reason = error.get("reason").toString();
logger.warn(" {}:{} > {}", new Object[] {line, character, reason});
}
}
}
}