Code coverage report for lib/reporters/jshint-reporter.js

Statements: 65% (13 / 20)      Branches: 50% (2 / 4)      Functions: 25% (1 / 4)      Lines: 65% (13 / 20)      Ignored: none     

All files » lib/reporters/ » jshint-reporter.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94    1 1               1           1           1           1           1               1             1         1             1                                       1                   1  
'use strict';
 
var JshintAdapter = require('../util/jshint-adapter');
var AbstractReporter = require('./abstract-reporter');
 
/**
 * @param {Function} reporter
 * @param {Object=} options
 * @extends {AbstractReporter}
 * @constructor
 */
var JshintReporter = function(reporter, options)
{
  /**
   * @type {Function}
   * @private
   */
  this.reporter_ = reporter;
 
  /**
   * @type {JshintAdapter}
   * @private
   */
  this.adapter_ = JshintAdapter;
 
  /**
   * @type {Object|{}}
   * @private
   */
  this.options_ = options || {};
 
  /**
   * @type {Array}
   * @private
   */
  this.buffer_ = [];
};
 
/**
 * Inherit from AbstractController.
 *
 * @type {AbstractReporter}
 */
JshintReporter.prototype = new AbstractReporter();
 
/**
 * Reset constructor.
 *
 * @type {JshintAdapter}
 */
JshintReporter.prototype.constructor = JshintReporter;
 
/**
 * @type {string}
 */
JshintReporter.REPORTER_NAME = 'jshint';
 
/**
 * @param {File} file
 * @param {String} encoding
 * @param {Function} callback
 */
JshintReporter.prototype.processFile = function(file, encoding, callback)
{
  file = this.adapter_.parseFile(file);
 
  if (!file.jshint.success) {
    this.reporter_(
      file.jshint.results,
      file.jshint.data,
      this.options_
    );
  }
 
  this.buffer_.push(file);
 
  callback();
};
 
/**
 * Called after all files have been processed.
 */
JshintReporter.prototype.flush = function()
{
  this.buffer_.forEach(function(file) {
    this.stream.push(file);
  }, this);
};
 
/**
 * @type {JshintReporter}
 */
module.exports = JshintReporter;