markdown.js
function renderStats(stats) {

  /**
   * Creates table Header if necessary
   * @param {string} type error or warning
   * @returns {string} The formatted string
   */
  function injectHeader(type) {
    return (stats[type]) ? '| rule | count | visual |\n| --- | --- | --- |\n' : '';
  }

  /**
   * renders templates for each rule
   * @param {string} type error or warning
   * @returns {string} The formatted string, pluralized where necessary
   */
  function output(type) {
    var statstype = stats[type];
    return injectHeader(type) + lodash.map(statstype, function (ruleStats, ruleId) {
      return statsRowTemplate({
        ruleId: ruleId,
        ruleCount: ruleStats,
        visual: lodash.repeat('X', lodash.min([ruleStats, 20]))
      });
    }, '').join('');
  }

  /**
   * render template for severity
   * @param {string} type severity
   * @returns {string} template
   */
  function renderTemplate(type) {
    var lcType = lodash.lowerCase(type);
    if (lodash.size(stats[lcType])) {
      return statsTemplate({
        title: '### ' + type,
        items: output(lcType)
      });
    } else {
      return '';
    }
  }

  return renderTemplate('Errors') + renderTemplate('Warnings');
}
function renderStats(stats) {

  /**
   * Creates table Header if necessary
   * @param {string} type error or warning
   * @returns {string} The formatted string
   */
  function injectHeader(type) {
    return (stats[type]) ? '| rule | count | visual |\n| --- | --- | --- |\n' : '';
  }

  /**
   * renders templates for each rule
   * @param {string} type error or warning
   * @returns {string} The formatted string, pluralized where necessary
   */
  function output(type) {
    var statstype = stats[type];
    return injectHeader(type) + lodash.map(statstype, function (ruleStats, ruleId) {
      return statsRowTemplate({
        ruleId: ruleId,
        ruleCount: ruleStats,
        visual: lodash.repeat('X', lodash.min([ruleStats, 20]))
      });
    }, '').join('');
  }

  /**
   * render template for severity
   * @param {string} type severity
   * @returns {string} template
   */
  function renderTemplate(type) {
    var lcType = lodash.lowerCase(type);
    if (lodash.size(stats[lcType])) {
      return statsTemplate({
        title: '### ' + type,
        items: output(lcType)
      });
    } else {
      return '';
    }
  }

  return renderTemplate('Errors') + renderTemplate('Warnings');
}
function renderStats ( stats ) { /**
   * Creates table Header if necessary
   * @param {string} type error or warning
   * @returns {string} The formatted string
   */ function injectHeader ( type ) { return ( stats [ type ] ) ? '| rule | count | visual |\n| --- | --- | --- |\n' : '' ; } /**
   * renders templates for each rule
   * @param {string} type error or warning
   * @returns {string} The formatted string, pluralized where necessary
   */ function output ( type ) { var statstype = stats [ type ] ; return injectHeader ( type ) + lodash . map ( statstype , function ( ruleStats , ruleId ) { return statsRowTemplate ( { ruleId : ruleId , ruleCount : ruleStats , visual : lodash . repeat ( 'X' , lodash . min ( [ ruleStats , 20 ] ) ) } ) ; } , '' ) . join ( '' ) ; } /**
   * render template for severity
   * @param {string} type severity
   * @returns {string} template
   */ function renderTemplate ( type ) { var lcType = lodash . lowerCase ( type ) ; if ( lodash . size ( stats [ lcType ] ) ) { return statsTemplate ( { title : '### ' + type , items : output ( lcType ) } ) ; } else { return '' ; } } return renderTemplate ( 'Errors' ) + renderTemplate ( 'Warnings' ) ; }
Renders MARKDOWN for stats
@param {Object} stats the rules and their stats
@returns {string} The formatted string, pluralized where necessary
Renders MARKDOWN for stats