Permalink
Browse files

* auto lint validation corrections

* added some ansi console codes
  • Loading branch information...
1 parent 881a4fb commit 74e30c77c0528bd3d1043c73e1107d6ba44d278c Julien Polo committed Dec 23, 2010
@@ -1,3 +1,4 @@
+/*jslint indent:4 */
var assert = require('assert');
var fs = require('fs');
var lint = require('../lint/parser');
View
@@ -5,9 +5,9 @@
/*******************************************************************************
* Report class
- *
+ *
* Usage:
- *
+ *
* <pre>
* var report = new Report();
* report.addFile('foo.js', [
@@ -20,7 +20,7 @@
******************************************************************************/
/**
* Report constructor
- *
+ *
* @constructor
* @return
*/
@@ -31,26 +31,26 @@ function Report() {
/**
* Add file report
- *
+ *
* @param {string} filePath
* @param {Array} errors
* @return
*/
Report.prototype.addFile = function (filePath, errors) {
errors = errors || [];
-
+
this._files[filePath] = {};
this._files[filePath].file = filePath;
this._files[filePath].errors = errors;
this._files[filePath].isValid = errors.length === 0;
-
+
this._count += errors.length;
return this;
};
/**
* Return the file report
- *
+ *
* @param {string} file
* @return {Object}
*/
@@ -59,13 +59,13 @@ Report.prototype.getFile = function (file) {
};
/**
- *
+ *
* @param {string} file
* @return {int}
*/
Report.prototype.countFile = function (file) {
var fileIterator, count;
-
+
count = 0;
for (fileIterator in this._files) {
if (this._files.hasOwnProperty(fileIterator)) {
@@ -76,7 +76,7 @@ Report.prototype.countFile = function (file) {
};
/**
- *
+ *
* @param {string} file
* @return {int}
*/
@@ -89,13 +89,13 @@ Report.prototype.countErrors = function (file) {
/**
* Iterate over the file reports
- *
+ *
* @param {Function} iterator
* @return this
*/
Report.prototype.forEach = function (iterator) {
var file;
-
+
for (file in this._files) {
if (this._files.hasOwnProperty(file)) {
iterator(this._files[file], file);
@@ -106,24 +106,24 @@ Report.prototype.forEach = function (iterator) {
/*******************************************************************************
* Formatter class
- *
+ *
* Usage:
- *
+ *
* <pre>
* var formatter = new Formatter({type: 'json'});
- *
+ *
* formatter.formater( report)//report is instance of Report
* </pre>
******************************************************************************/
/**
* Formatter constructor
- *
+ *
* @constructor
*/
function Formatter(options) {
this._adapterType = 'cli';
this._adapter = null;
-
+
this.configure(options);
}
@@ -133,37 +133,37 @@ Formatter.FULL = 'full';
/**
* Return the adapter from configuration
- *
+ *
* @return {Base}
*/
Formatter.prototype._getAdapter = function () {
if (!this._adapter) {
- var formatterModule, FormatterClass;
-
+ var formatterModule, FormatterClass, options;
+
options = {
type: this._adapterType,
mode: Formatter.NORMAL
};
-
+
try {
formatterModule = require('./formatter/' + options.type);
} catch (e) {
throw new Error('Formatter "' + options.type + '" not found');
}
FormatterClass = formatterModule.Formatter;
-
+
if (FormatterClass === undefined) {
throw new Error('Formatter class not found in module "' + options.type + '"');
}
-
+
this._adapter = new FormatterClass(options);
}
return this._adapter;
};
/**
* Configure the formatter
- *
+ *
* @return this
*/
Formatter.prototype.configure = function (options) {
@@ -172,14 +172,14 @@ Formatter.prototype.configure = function (options) {
this._adapterType = options.type;
this._adapter = null;
}
-
+
this._getAdapter().configure(options);
return this;
};
/**
* Return a formatted text
- *
+ *
* @return {string}
*/
Formatter.prototype.format = function (report) {
@@ -188,14 +188,14 @@ Formatter.prototype.format = function (report) {
/*******************************************************************************
* Base class
- *
+ *
* Usage:
- *
+ *
* > inherits from this class to create a new formatter
******************************************************************************/
/**
* Base constructor
- *
+ *
* @constructor
* @param {Object} options
*/
@@ -214,14 +214,14 @@ function Base(options) {
/**
* Configure the formatter
- *
+ *
* @param {Object} options
* - mode: quantity of information displayed (= simple|normal|full)
* - encoding: character encoding utf-8
* - tab: tabulation character used (default: "\t")
* - eol: end of line character (default: "\n")
* - limit: limit the error count (default: null)
- *
+ *
* @return this
*/
Base.prototype.configure = function (options) {
@@ -247,7 +247,7 @@ Base.prototype.configure = function (options) {
if (options.eol !== undefined) {
this.eol = options.eol;
}
-
+
if (options.limit !== undefined) {
this.limit = options.limit;
}
@@ -257,7 +257,7 @@ Base.prototype.configure = function (options) {
/**
* Return formatted data
- *
+ *
* @param {Object} data
* @param {string} mode
* @return {string}
@@ -266,7 +266,7 @@ Base.prototype.format = function (report, mode) {
if (report === undefined) {
throw new Error('`report` should not be undefined');
}
-
+
if (!(report instanceof Report)) {
throw new Error('`report` should be an instance of Report.');
}
@@ -288,7 +288,7 @@ Base.prototype.format = function (report, mode) {
/**
* Return simple formatted content (can be overriden)
- *
+ *
* @return {string}
*/
Base.prototype._formatSimple = function (report) {
@@ -297,7 +297,7 @@ Base.prototype._formatSimple = function (report) {
/**
* Return normal formatted content (can be overriden)
- *
+ *
* @return {string}
*/
Base.prototype._formatNormal = function (report) {
@@ -306,7 +306,7 @@ Base.prototype._formatNormal = function (report) {
/**
* Return full formatted content (can be overriden)
- *
+ *
* @return {string}
*/
Base.prototype._formatFull = function (report) {
Oops, something went wrong.

0 comments on commit 74e30c7

Please sign in to comment.