jscs-html-pretty-reporter
Advanced tools
Comparing version 0.1.3 to 0.2.0
78
index.js
@@ -11,2 +11,10 @@ var fs = require('fs'), | ||
this.errorAttrs = [ | ||
'filename', | ||
'rule', | ||
'line', | ||
'column', | ||
'message' | ||
]; | ||
this.summarizeFile = function(file, alert) { | ||
@@ -34,21 +42,21 @@ var messages = { | ||
this.summarizeData = function(files) { | ||
_.each(files, _.bind(function eachFile(file) { | ||
var entry = { | ||
path: file.filename, | ||
errors: 0, | ||
warnings: 0, | ||
messages: [], | ||
errorList: [] | ||
}, | ||
alerts = file.errors; | ||
this.eachFile = function(file) { | ||
var entry = { | ||
path: file.filename, | ||
errors: 0, | ||
warnings: 0, | ||
messages: [], | ||
errorList: [] | ||
}, | ||
alerts = file.errors; | ||
_.each(alerts, _.bind(function eachAlert(alert) { | ||
entry = this.summarizeFile(entry, alert); | ||
}, this)); | ||
_.each(alerts, _.partial(this.summarizeFile, entry)); | ||
hairballs.updateFileSummary(entry); | ||
}, this)); | ||
hairballs.updateFileSummary(entry); | ||
}; | ||
this.summarizeData = function(files) { | ||
_.each(files, this.eachFile); | ||
}; | ||
this.runReport = function(input) { | ||
@@ -72,26 +80,32 @@ this.summarizeData(input); | ||
this.saveHandler = function(err) { | ||
if (err) { | ||
throw err; | ||
} | ||
} | ||
this.save = function(data) { | ||
fs.writeFile(this.outputPath, templateUtils.applyTemplates(data), function writeHandler(err) { | ||
if (err) { | ||
throw err; | ||
} | ||
}); | ||
fs.writeFile(this.outputPath, templateUtils.applyTemplates(data), this.saveHandler); | ||
}; | ||
results = _.map(input, function inputMapper(file) { | ||
this.mapError = function(error) { | ||
return _.pick(error, this.errorAttrs); | ||
}; | ||
this.mapInput = function(file) { | ||
return { | ||
errors: _.map(file._errorList, function errorMapper(error) { | ||
return _.pick(error, [ | ||
'filename', | ||
'rule', | ||
'line', | ||
'column', | ||
'message' | ||
]); | ||
}), | ||
errors: _.map(file._errorList, this.mapError), | ||
filename: file._file._filename | ||
}; | ||
}); | ||
}; | ||
this.save(this.runReport(results)); | ||
_.bindAll(this, [ | ||
'summarizeData', | ||
'summarizeFile', | ||
'eachFile', | ||
'mapError', | ||
'mapInput' | ||
]); | ||
this.save(this.runReport(_.map(input, this.mapInput))); | ||
}; |
{ | ||
"name": "jscs-html-pretty-reporter", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "An HTML reporter for JSCS using Hairballs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3372
88