code: function getStats(results) {
  
    /**
     * calculate stats for each severity
     * @param {string} type  severity
     * @returns {Object} stats
     */
    function filterMessages(type) {
      return lodash(results)
        .map('messages')
        .flatten()
        .filter(function (message) { return message.severity === type; })
        .groupBy('ruleId')
        .mapValues(function (ruleMessages) {
          return ruleMessages.length;
        })
        .value();
    }
    return {
      errors: filterMessages(2),
      warnings: filterMessages(1)
    };
  }
docs: Calculate stats
  @param {Array}    results  results
  @returns {Object} stats