|
| 1 | +/*jslint node:true*/ |
| 2 | + |
| 3 | +var LintError = require('./lint-error.js'); |
| 4 | + |
| 5 | +/*jslint regexp:true*/ |
| 6 | +var expressions = { |
| 7 | + // Done processing /Users/stephenmathieson/work/amaze/signing/amaze-cpp-signing-extension-stephen/CPPSigningExtension.cc |
| 8 | + 'done': { |
| 9 | + 'is': /Done processing [\/a-z\-\_\.\d]+/i, |
| 10 | + 'file': / ([\/a-z\-\_\.\d]+)$/i |
| 11 | + }, |
| 12 | + // /Users/stephenmathieson/work/amaze/signing/amaze-cpp-signing-extension-stephen/CPPSigningExtension.cc:302: Blank line at the end of a code block. Is this needed? [whitespace/blank_line] [3] |
| 13 | + 'error': { |
| 14 | + 'is': /[\/a-z-_\.]+\:[\d]+\:[ ]{2}.*\[[1-5]\]/i |
| 15 | + } |
| 16 | +}; |
| 17 | + |
| 18 | +/** |
| 19 | + * [parseOutput description] |
| 20 | + * |
| 21 | + * @param {String} output |
| 22 | + * @param {Function} next |
| 23 | + * @return {[type]} |
| 24 | + */ |
| 25 | +function parseOutput(output, next) { |
| 26 | + 'use strict'; |
| 27 | + |
| 28 | + var errors = [], error, |
| 29 | + report = {}, |
| 30 | + lines = output.split('\n').filter(function (line) { |
| 31 | + if (line) { |
| 32 | + return true; |
| 33 | + } |
| 34 | + |
| 35 | + return false; |
| 36 | + }); |
| 37 | + |
| 38 | + lines.forEach(function (line) { |
| 39 | + |
| 40 | + var filename; |
| 41 | + |
| 42 | + if (line.match(expressions.done.is)) { |
| 43 | + |
| 44 | + filename = line.match(expressions.done.file)[1]; |
| 45 | + |
| 46 | + if (!report.hasOwnProperty(filename)) { |
| 47 | + report[filename] = []; |
| 48 | + } |
| 49 | + |
| 50 | + } |
| 51 | + |
| 52 | + if (line.match(expressions.error.is)) { |
| 53 | + error = new LintError(line); |
| 54 | + filename = error.file; |
| 55 | + |
| 56 | + if (!report.hasOwnProperty(filename)) { |
| 57 | + report[filename] = []; |
| 58 | + } |
| 59 | + |
| 60 | + report[filename].push(error); |
| 61 | + |
| 62 | + } |
| 63 | + |
| 64 | + }); |
| 65 | + |
| 66 | + return next(null, report); |
| 67 | + //return next(null, errors); |
| 68 | + |
| 69 | +} |
| 70 | + |
| 71 | +module.exports = parseOutput; |
0 commit comments