diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:38:50 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:40:43 +0200 |
commit | 7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch) | |
tree | 6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/istanbul-reports/lib/lcovonly | |
parent | 963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff) |
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/istanbul-reports/lib/lcovonly')
-rw-r--r-- | node_modules/istanbul-reports/lib/lcovonly/index.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/node_modules/istanbul-reports/lib/lcovonly/index.js b/node_modules/istanbul-reports/lib/lcovonly/index.js new file mode 100644 index 000000000..6d436e42b --- /dev/null +++ b/node_modules/istanbul-reports/lib/lcovonly/index.js @@ -0,0 +1,69 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +function LcovOnlyReport(opts) { + this.file = opts.file || 'lcov.info'; + this.contentWriter = null; +} + +LcovOnlyReport.prototype.onStart = function (root, context) { + this.contentWriter = context.writer.writeFile(this.file); +}; + +LcovOnlyReport.prototype.onDetail = function (node) { + + var fc = node.getFileCoverage(), + writer = this.contentWriter, + functions = fc.f, + functionMap = fc.fnMap, + lines = fc.getLineCoverage(), + branches = fc.b, + branchMap = fc.branchMap, + summary = node.getCoverageSummary(); + + writer.println('TN:'); //no test name + writer.println('SF:' + fc.path); + + Object.keys(functions).forEach(function (key) { + var meta = functionMap[key]; + writer.println('FN:' + [meta.decl.start.line, meta.name].join(',')); + }); + writer.println('FNF:' + summary.functions.total); + writer.println('FNH:' + summary.functions.covered); + + Object.keys(functions).forEach(function (key) { + var stats = functions[key], + meta = functionMap[key]; + writer.println('FNDA:' + [stats, meta.name].join(',')); + }); + + Object.keys(lines).forEach(function (key) { + var stat = lines[key]; + writer.println('DA:' + [key, stat].join(',')); + }); + writer.println('LF:' + summary.lines.total); + writer.println('LH:' + summary.lines.covered); + + Object.keys(branches).forEach(function (key) { + var branchArray = branches[key], + meta = branchMap[key], + line = meta.loc.start.line, + i = 0; + branchArray.forEach(function (b) { + writer.println('BRDA:' + [line, key, i, b].join(',')); + i += 1; + }); + }); + writer.println('BRF:' + summary.branches.total); + writer.println('BRH:' + summary.branches.covered); + writer.println('end_of_record'); +}; + +LcovOnlyReport.prototype.onEnd = function () { + this.contentWriter.close(); +}; + +module.exports = LcovOnlyReport; |