Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

istanbul-reports

Package Overview
Dependencies
Maintainers
4
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

istanbul-reports - npm Package Compare versions

Comparing version 2.2.6 to 3.0.0-alpha.0

lib/html-spa/.babelrc

15

CHANGELOG.md

@@ -6,13 +6,22 @@ # Change Log

## [2.2.6]
# [3.0.0-alpha.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-reports@2.2.5...istanbul-reports@3.0.0-alpha.0) (2019-06-19)
### Bug Fixes
### Features
* **istanbul-reports:** Revert to istanbul-reports@2.2.4
* Refactor istanbul-lib-report so report can choose summarizer ([#408](https://github.com/istanbuljs/istanbuljs/issues/408)) ([0f328fd](https://github.com/istanbuljs/istanbuljs/commit/0f328fd))
* **text report:** Optimize output to show more missing lines ([#341](https://github.com/istanbuljs/istanbuljs/issues/341)) ([c4e8b8e](https://github.com/istanbuljs/istanbuljs/commit/c4e8b8e))
* Modern html report ([#345](https://github.com/istanbuljs/istanbuljs/issues/345)) ([95ebaf1](https://github.com/istanbuljs/istanbuljs/commit/95ebaf1))
* Update dependencies, require Node.js 8 ([#401](https://github.com/istanbuljs/istanbuljs/issues/401)) ([bf3a539](https://github.com/istanbuljs/istanbuljs/commit/bf3a539))
### BREAKING CHANGES
* Existing istanbul-lib-report API's have been changed
* Node.js 8 is now required
## [2.2.5](https://github.com/istanbuljs/istanbuljs/compare/istanbul-reports@2.2.4...istanbul-reports@2.2.5) (2019-05-02)

@@ -19,0 +28,0 @@

1

index.js

@@ -0,1 +1,2 @@

'use strict';
/*

@@ -2,0 +3,0 @@ Copyright 2012-2015, Yahoo Inc.

@@ -0,1 +1,2 @@

'use strict';
/*

@@ -5,160 +6,160 @@ Copyright 2012-2015, Yahoo Inc.

*/
function CloverReport(opts) {
this.cw = null;
this.xml = null;
this.projectRoot = opts.projectRoot || process.cwd();
this.file = opts.file || 'clover.xml';
}
const { ReportBase } = require('istanbul-lib-report');
function asJavaPackage(node) {
return node
.getRelativeName()
.replace(/\//g, '.')
.replace(/\\/g, '.')
.replace(/\.$/, '');
}
class CloverReport extends ReportBase {
constructor(opts) {
super();
function asClassName(node) {
return node.getRelativeName().replace(/.*[\\/]/, '');
}
this.cw = null;
this.xml = null;
this.projectRoot = opts.projectRoot || process.cwd();
this.file = opts.file || 'clover.xml';
}
CloverReport.prototype.onStart = function(root, context) {
this.cw = context.writer.writeFile(this.file);
this.xml = context.getXMLWriter(this.cw);
this.writeRootStats(root, context);
};
onStart(root, context) {
this.cw = context.writer.writeFile(this.file);
this.xml = context.getXMLWriter(this.cw);
this.writeRootStats(root, context);
}
CloverReport.prototype.onEnd = function() {
this.xml.closeAll();
this.cw.close();
};
onEnd() {
this.xml.closeAll();
this.cw.close();
}
CloverReport.prototype.getTreeStats = function(node, context) {
const state = {
packages: 0,
files: 0,
classes: 0
};
const visitor = {
onSummary(node, state) {
const metrics = node.getCoverageSummary(true);
if (metrics) {
state.packages += 1;
getTreeStats(node, context) {
const state = {
packages: 0,
files: 0,
classes: 0
};
const visitor = {
onSummary(node, state) {
const metrics = node.getCoverageSummary(true);
if (metrics) {
state.packages += 1;
}
},
onDetail(node, state) {
state.classes += 1;
state.files += 1;
}
},
onDetail(node, state) {
state.classes += 1;
state.files += 1;
}
};
node.visit(context.getVisitor(visitor), state);
return state;
};
};
node.visit(context.getVisitor(visitor), state);
return state;
}
CloverReport.prototype.writeRootStats = function(node, context) {
const metrics = node.getCoverageSummary();
const attrs = {
statements: metrics.lines.total,
coveredstatements: metrics.lines.covered,
conditionals: metrics.branches.total,
coveredconditionals: metrics.branches.covered,
methods: metrics.functions.total,
coveredmethods: metrics.functions.covered,
elements:
metrics.lines.total +
metrics.branches.total +
metrics.functions.total,
coveredelements:
metrics.lines.covered +
metrics.branches.covered +
metrics.functions.covered,
complexity: 0,
loc: metrics.lines.total,
ncloc: metrics.lines.total // what? copied as-is from old report
};
writeRootStats(node, context) {
this.cw.println('<?xml version="1.0" encoding="UTF-8"?>');
this.xml.openTag('coverage', {
generated: Date.now().toString(),
clover: '3.2.0'
});
this.cw.println('<?xml version="1.0" encoding="UTF-8"?>');
this.xml.openTag('coverage', {
generated: Date.now().toString(),
clover: '3.2.0'
});
this.xml.openTag('project', {
timestamp: Date.now().toString(),
name: 'All files'
});
this.xml.openTag('project', {
timestamp: Date.now().toString(),
name: 'All files'
});
const metrics = node.getCoverageSummary();
this.xml.inlineTag('metrics', {
statements: metrics.lines.total,
coveredstatements: metrics.lines.covered,
conditionals: metrics.branches.total,
coveredconditionals: metrics.branches.covered,
methods: metrics.functions.total,
coveredmethods: metrics.functions.covered,
elements:
metrics.lines.total +
metrics.branches.total +
metrics.functions.total,
coveredelements:
metrics.lines.covered +
metrics.branches.covered +
metrics.functions.covered,
complexity: 0,
loc: metrics.lines.total,
ncloc: metrics.lines.total, // what? copied as-is from old report
...this.getTreeStats(node, context)
});
}
const treeStats = this.getTreeStats(node, context);
Object.keys(treeStats).forEach(k => {
attrs[k] = treeStats[k];
});
writeMetrics(metrics) {
this.xml.inlineTag('metrics', {
statements: metrics.lines.total,
coveredstatements: metrics.lines.covered,
conditionals: metrics.branches.total,
coveredconditionals: metrics.branches.covered,
methods: metrics.functions.total,
coveredmethods: metrics.functions.covered
});
}
this.xml.inlineTag('metrics', attrs);
};
onSummary(node) {
if (node.isRoot()) {
return;
}
const metrics = node.getCoverageSummary(true);
if (!metrics) {
return;
}
CloverReport.prototype.writeMetrics = function(metrics) {
this.xml.inlineTag('metrics', {
statements: metrics.lines.total,
coveredstatements: metrics.lines.covered,
conditionals: metrics.branches.total,
coveredconditionals: metrics.branches.covered,
methods: metrics.functions.total,
coveredmethods: metrics.functions.covered
});
};
this.xml.openTag('package', {
name: asJavaPackage(node)
});
this.writeMetrics(metrics);
}
CloverReport.prototype.onSummary = function(node) {
if (node.isRoot()) {
return;
onSummaryEnd(node) {
if (node.isRoot()) {
return;
}
this.xml.closeTag('package');
}
const metrics = node.getCoverageSummary(true);
if (!metrics) {
return;
}
this.xml.openTag('package', {
name: asJavaPackage(node)
});
this.writeMetrics(metrics);
};
onDetail(node) {
const fileCoverage = node.getFileCoverage();
const metrics = node.getCoverageSummary();
const branchByLine = fileCoverage.getBranchCoverageByLine();
CloverReport.prototype.onSummaryEnd = function(node) {
if (node.isRoot()) {
return;
}
this.xml.closeTag('package');
};
this.xml.openTag('file', {
name: asClassName(node),
path: fileCoverage.path
});
CloverReport.prototype.onDetail = function(node) {
const fileCoverage = node.getFileCoverage();
const metrics = node.getCoverageSummary();
const branchByLine = fileCoverage.getBranchCoverageByLine();
this.writeMetrics(metrics);
this.xml.openTag('file', {
name: asClassName(node),
path: fileCoverage.path
});
const lines = fileCoverage.getLineCoverage();
Object.entries(lines).forEach(([k, count]) => {
const attrs = {
num: k,
count,
type: 'stmt'
};
const branchDetail = branchByLine[k];
this.writeMetrics(metrics);
if (branchDetail) {
attrs.type = 'cond';
attrs.truecount = branchDetail.covered;
attrs.falsecount = branchDetail.total - branchDetail.covered;
}
this.xml.inlineTag('line', attrs);
});
const lines = fileCoverage.getLineCoverage();
Object.keys(lines).forEach(k => {
const attrs = {
num: k,
count: lines[k],
type: 'stmt'
};
const branchDetail = branchByLine[k];
this.xml.closeTag('file');
}
}
if (branchDetail) {
attrs.type = 'cond';
attrs.truecount = branchDetail.covered;
attrs.falsecount = branchDetail.total - branchDetail.covered;
}
this.xml.inlineTag('line', attrs);
});
function asJavaPackage(node) {
return node
.getRelativeName()
.replace(/\//g, '.')
.replace(/\\/g, '.')
.replace(/\.$/, '');
}
this.xml.closeTag('file');
};
function asClassName(node) {
return node.getRelativeName().replace(/.*[\\/]/, '');
}
module.exports = CloverReport;

@@ -0,1 +1,2 @@

'use strict';
/*

@@ -6,139 +7,144 @@ Copyright 2012-2015, Yahoo Inc.

const path = require('path');
function CoberturaReport(opts) {
this.cw = null;
this.xml = null;
this.projectRoot = opts.projectRoot || process.cwd();
this.file = opts.file || 'cobertura-coverage.xml';
}
const { ReportBase } = require('istanbul-lib-report');
function asJavaPackage(node) {
return node
.getRelativeName()
.replace(/\//g, '.')
.replace(/\\/g, '.')
.replace(/\.$/, '');
}
class CoberturaReport extends ReportBase {
constructor(opts) {
super();
function asClassName(node) {
return node.getRelativeName().replace(/.*[\\/]/, '');
}
this.cw = null;
this.xml = null;
this.projectRoot = opts.projectRoot || process.cwd();
this.file = opts.file || 'cobertura-coverage.xml';
}
CoberturaReport.prototype.onStart = function(root, context) {
this.cw = context.writer.writeFile(this.file);
this.xml = context.getXMLWriter(this.cw);
this.writeRootStats(root);
};
onStart(root, context) {
this.cw = context.writer.writeFile(this.file);
this.xml = context.getXMLWriter(this.cw);
this.writeRootStats(root);
}
CoberturaReport.prototype.onEnd = function() {
this.xml.closeAll();
this.cw.close();
};
onEnd() {
this.xml.closeAll();
this.cw.close();
}
CoberturaReport.prototype.writeRootStats = function(node) {
const metrics = node.getCoverageSummary();
this.cw.println('<?xml version="1.0" ?>');
this.cw.println(
'<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">'
);
this.xml.openTag('coverage', {
'lines-valid': metrics.lines.total,
'lines-covered': metrics.lines.covered,
'line-rate': metrics.lines.pct / 100.0,
'branches-valid': metrics.branches.total,
'branches-covered': metrics.branches.covered,
'branch-rate': metrics.branches.pct / 100.0,
timestamp: Date.now().toString(),
complexity: '0',
version: '0.1'
});
this.xml.openTag('sources');
this.xml.inlineTag('source', null, this.projectRoot);
this.xml.closeTag('sources');
this.xml.openTag('packages');
};
writeRootStats(node) {
const metrics = node.getCoverageSummary();
this.cw.println('<?xml version="1.0" ?>');
this.cw.println(
'<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">'
);
this.xml.openTag('coverage', {
'lines-valid': metrics.lines.total,
'lines-covered': metrics.lines.covered,
'line-rate': metrics.lines.pct / 100.0,
'branches-valid': metrics.branches.total,
'branches-covered': metrics.branches.covered,
'branch-rate': metrics.branches.pct / 100.0,
timestamp: Date.now().toString(),
complexity: '0',
version: '0.1'
});
this.xml.openTag('sources');
this.xml.inlineTag('source', null, this.projectRoot);
this.xml.closeTag('sources');
this.xml.openTag('packages');
}
CoberturaReport.prototype.onSummary = function(node) {
if (node.isRoot()) {
return;
onSummary(node) {
if (node.isRoot()) {
return;
}
const metrics = node.getCoverageSummary(true);
if (!metrics) {
return;
}
this.xml.openTag('package', {
name: asJavaPackage(node),
'line-rate': metrics.lines.pct / 100.0,
'branch-rate': metrics.branches.pct / 100.0
});
this.xml.openTag('classes');
}
const metrics = node.getCoverageSummary(true);
if (!metrics) {
return;
}
this.xml.openTag('package', {
name: asJavaPackage(node),
'line-rate': metrics.lines.pct / 100.0,
'branch-rate': metrics.branches.pct / 100.0
});
this.xml.openTag('classes');
};
CoberturaReport.prototype.onSummaryEnd = function(node) {
if (node.isRoot()) {
return;
onSummaryEnd(node) {
if (node.isRoot()) {
return;
}
this.xml.closeTag('classes');
this.xml.closeTag('package');
}
this.xml.closeTag('classes');
this.xml.closeTag('package');
};
CoberturaReport.prototype.onDetail = function(node) {
const fileCoverage = node.getFileCoverage();
const metrics = node.getCoverageSummary();
const branchByLine = fileCoverage.getBranchCoverageByLine();
onDetail(node) {
const fileCoverage = node.getFileCoverage();
const metrics = node.getCoverageSummary();
const branchByLine = fileCoverage.getBranchCoverageByLine();
this.xml.openTag('class', {
name: asClassName(node),
filename: path.relative(this.projectRoot, fileCoverage.path),
'line-rate': metrics.lines.pct / 100.0,
'branch-rate': metrics.branches.pct / 100.0
});
this.xml.openTag('class', {
name: asClassName(node),
filename: path.relative(this.projectRoot, fileCoverage.path),
'line-rate': metrics.lines.pct / 100.0,
'branch-rate': metrics.branches.pct / 100.0
});
this.xml.openTag('methods');
const fnMap = fileCoverage.fnMap;
Object.keys(fnMap).forEach(k => {
const name = fnMap[k].name;
const hits = fileCoverage.f[k];
this.xml.openTag('method', {
name,
hits,
signature: '()V' //fake out a no-args void return
this.xml.openTag('methods');
const fnMap = fileCoverage.fnMap;
Object.entries(fnMap).forEach(([k, { name, decl }]) => {
const hits = fileCoverage.f[k];
this.xml.openTag('method', {
name,
hits,
signature: '()V' //fake out a no-args void return
});
this.xml.openTag('lines');
//Add the function definition line and hits so that jenkins cobertura plugin records method hits
this.xml.inlineTag('line', {
number: decl.start.line,
hits
});
this.xml.closeTag('lines');
this.xml.closeTag('method');
});
this.xml.closeTag('methods');
this.xml.openTag('lines');
//Add the function definition line and hits so that jenkins cobertura plugin records method hits
this.xml.inlineTag('line', {
number: fnMap[k].decl.start.line,
hits
const lines = fileCoverage.getLineCoverage();
Object.entries(lines).forEach(([k, hits]) => {
const attrs = {
number: k,
hits,
branch: 'false'
};
const branchDetail = branchByLine[k];
if (branchDetail) {
attrs.branch = true;
attrs['condition-coverage'] =
branchDetail.coverage +
'% (' +
branchDetail.covered +
'/' +
branchDetail.total +
')';
}
this.xml.inlineTag('line', attrs);
});
this.xml.closeTag('lines');
this.xml.closeTag('method');
});
this.xml.closeTag('methods');
this.xml.closeTag('class');
}
}
this.xml.openTag('lines');
const lines = fileCoverage.getLineCoverage();
Object.keys(lines).forEach(k => {
const attrs = {
number: k,
hits: lines[k],
branch: 'false'
};
const branchDetail = branchByLine[k];
function asJavaPackage(node) {
return node
.getRelativeName()
.replace(/\//g, '.')
.replace(/\\/g, '.')
.replace(/\.$/, '');
}
if (branchDetail) {
attrs.branch = true;
attrs['condition-coverage'] =
branchDetail.coverage +
'% (' +
branchDetail.covered +
'/' +
branchDetail.total +
')';
}
this.xml.inlineTag('line', attrs);
});
function asClassName(node) {
return node.getRelativeName().replace(/.*[\\/]/, '');
}
this.xml.closeTag('lines');
this.xml.closeTag('class');
};
module.exports = CoberturaReport;

@@ -37,4 +37,3 @@ /*

}
Object.keys(lineStats).forEach(lineNumber => {
const count = lineStats[lineNumber];
Object.entries(lineStats).forEach(([lineNumber, count]) => {
if (structuredText[lineNumber]) {

@@ -50,4 +49,3 @@ structuredText[lineNumber].covered = count > 0 ? 'yes' : 'no';

const statementMeta = fileCoverage.statementMap;
Object.keys(statementStats).forEach(stName => {
const count = statementStats[stName];
Object.entries(statementStats).forEach(([stName, count]) => {
const meta = statementMeta[stName];

@@ -90,4 +88,3 @@ const type = count > 0 ? 'yes' : 'no';

}
Object.keys(fnStats).forEach(fName => {
const count = fnStats[fName];
Object.entries(fnStats).forEach(([fName, count]) => {
const meta = fnMeta[fName];

@@ -131,4 +128,3 @@ const type = count > 0 ? 'yes' : 'no';

Object.keys(branchStats).forEach(branchName => {
const branchArray = branchStats[branchName];
Object.entries(branchStats).forEach(([branchName, branchArray]) => {
const sumCount = branchArray.reduce((p, n) => p + n, 0);

@@ -135,0 +131,0 @@ const metaArray = branchMeta[branchName].locations;

@@ -0,1 +1,2 @@

'use strict';
/*

@@ -2,0 +3,0 @@ Copyright 2012-2015, Yahoo Inc.

@@ -0,1 +1,2 @@

'use strict';
/*

@@ -8,2 +9,3 @@ Copyright 2012-2015, Yahoo Inc.

const handlebars = require('handlebars').create();
const { ReportBase } = require('istanbul-lib-report');
const annotator = require('./annotator');

@@ -111,4 +113,6 @@ const helpers = require('./helpers');

class HtmlReport {
class HtmlReport extends ReportBase {
constructor(opts) {
super();
this.verbose = opts.verbose;

@@ -115,0 +119,0 @@ this.linkMapper = opts.linkMapper || standardLinkMapper;

@@ -0,1 +1,2 @@

'use strict';
/*

@@ -2,0 +3,0 @@ Copyright 2012-2015, Yahoo Inc.

@@ -6,44 +6,52 @@ /*

'use strict';
const { ReportBase } = require('istanbul-lib-report');
function JsonSummaryReport(opts) {
this.file = opts.file || 'coverage-summary.json';
this.contentWriter = null;
this.first = true;
}
class JsonSummaryReport extends ReportBase {
constructor(opts) {
super();
JsonSummaryReport.prototype.onStart = function(root, context) {
this.contentWriter = context.writer.writeFile(this.file);
this.contentWriter.write('{');
};
this.file = opts.file || 'coverage-summary.json';
this.contentWriter = null;
this.first = true;
}
JsonSummaryReport.prototype.writeSummary = function(filePath, sc) {
const cw = this.contentWriter;
if (this.first) {
this.first = false;
} else {
cw.write(',');
onStart(root, context) {
this.contentWriter = context.writer.writeFile(this.file);
this.contentWriter.write('{');
}
cw.write(JSON.stringify(filePath));
cw.write(': ');
cw.write(JSON.stringify(sc));
cw.println('');
};
JsonSummaryReport.prototype.onSummary = function(node) {
if (!node.isRoot()) {
return;
writeSummary(filePath, sc) {
const cw = this.contentWriter;
if (this.first) {
this.first = false;
} else {
cw.write(',');
}
cw.write(JSON.stringify(filePath));
cw.write(': ');
cw.write(JSON.stringify(sc));
cw.println('');
}
this.writeSummary('total', node.getCoverageSummary());
};
JsonSummaryReport.prototype.onDetail = function(node) {
this.writeSummary(node.getFileCoverage().path, node.getCoverageSummary());
};
onSummary(node) {
if (!node.isRoot()) {
return;
}
this.writeSummary('total', node.getCoverageSummary());
}
JsonSummaryReport.prototype.onEnd = function() {
const cw = this.contentWriter;
cw.println('}');
cw.close();
};
onDetail(node) {
this.writeSummary(
node.getFileCoverage().path,
node.getCoverageSummary()
);
}
onEnd() {
const cw = this.contentWriter;
cw.println('}');
cw.close();
}
}
module.exports = JsonSummaryReport;

@@ -6,35 +6,40 @@ /*

'use strict';
const { ReportBase } = require('istanbul-lib-report');
function JsonReport(opts) {
this.file = opts.file || 'coverage-final.json';
this.first = true;
}
class JsonReport extends ReportBase {
constructor(opts) {
super();
JsonReport.prototype.onStart = function(root, context) {
this.contentWriter = context.writer.writeFile(this.file);
this.contentWriter.write('{');
};
this.file = opts.file || 'coverage-final.json';
this.first = true;
}
JsonReport.prototype.onDetail = function(node) {
const fc = node.getFileCoverage();
const key = fc.path;
const cw = this.contentWriter;
onStart(root, context) {
this.contentWriter = context.writer.writeFile(this.file);
this.contentWriter.write('{');
}
if (this.first) {
this.first = false;
} else {
cw.write(',');
onDetail(node) {
const fc = node.getFileCoverage();
const key = fc.path;
const cw = this.contentWriter;
if (this.first) {
this.first = false;
} else {
cw.write(',');
}
cw.write(JSON.stringify(key));
cw.write(': ');
cw.write(JSON.stringify(fc));
cw.println('');
}
cw.write(JSON.stringify(key));
cw.write(': ');
cw.write(JSON.stringify(fc));
cw.println('');
};
JsonReport.prototype.onEnd = function() {
const cw = this.contentWriter;
cw.println('}');
cw.close();
};
onEnd() {
const cw = this.contentWriter;
cw.println('}');
cw.close();
}
}
module.exports = JsonReport;

@@ -0,1 +1,2 @@

'use strict';
/*

@@ -5,8 +6,13 @@ Copyright 2012-2015, Yahoo Inc.

*/
const { ReportBase } = require('istanbul-lib-report');
const LcovOnlyReport = require('../lcovonly');
const HtmlReport = require('../html');
function LcovReport() {
this.lcov = new LcovOnlyReport({ file: 'lcov.info' });
this.html = new HtmlReport({ subdir: 'lcov-report' });
class LcovReport extends ReportBase {
constructor() {
super();
this.lcov = new LcovOnlyReport({ file: 'lcov.info' });
this.html = new HtmlReport({ subdir: 'lcov-report' });
}
}

@@ -13,0 +19,0 @@

@@ -6,64 +6,62 @@ /*

'use strict';
const { ReportBase } = require('istanbul-lib-report');
function LcovOnlyReport(opts) {
this.file = opts.file || 'lcov.info';
this.contentWriter = null;
}
class LcovOnlyReport extends ReportBase {
constructor(opts) {
super();
this.file = opts.file || 'lcov.info';
this.contentWriter = null;
}
LcovOnlyReport.prototype.onStart = function(root, context) {
this.contentWriter = context.writer.writeFile(this.file);
};
onStart(root, context) {
this.contentWriter = context.writer.writeFile(this.file);
}
LcovOnlyReport.prototype.onDetail = function(node) {
const fc = node.getFileCoverage();
const writer = this.contentWriter;
const functions = fc.f;
const functionMap = fc.fnMap;
const lines = fc.getLineCoverage();
const branches = fc.b;
const branchMap = fc.branchMap;
const summary = node.getCoverageSummary();
onDetail(node) {
const fc = node.getFileCoverage();
const writer = this.contentWriter;
const functions = fc.f;
const functionMap = fc.fnMap;
const lines = fc.getLineCoverage();
const branches = fc.b;
const branchMap = fc.branchMap;
const summary = node.getCoverageSummary();
writer.println('TN:'); //no test name
writer.println('SF:' + fc.path);
writer.println('TN:'); //no test name
writer.println('SF:' + fc.path);
Object.keys(functionMap).forEach(key => {
const 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.values(functionMap).forEach(meta => {
writer.println('FN:' + [meta.decl.start.line, meta.name].join(','));
});
writer.println('FNF:' + summary.functions.total);
writer.println('FNH:' + summary.functions.covered);
Object.keys(functionMap).forEach(key => {
const stats = functions[key];
const meta = functionMap[key];
writer.println('FNDA:' + [stats, meta.name].join(','));
});
Object.entries(functionMap).forEach(([key, meta]) => {
const stats = functions[key];
writer.println('FNDA:' + [stats, meta.name].join(','));
});
Object.keys(lines).forEach(key => {
const stat = lines[key];
writer.println('DA:' + [key, stat].join(','));
});
writer.println('LF:' + summary.lines.total);
writer.println('LH:' + summary.lines.covered);
Object.entries(lines).forEach(entry => {
writer.println('DA:' + entry.join(','));
});
writer.println('LF:' + summary.lines.total);
writer.println('LH:' + summary.lines.covered);
Object.keys(branches).forEach(key => {
const branchArray = branches[key];
const meta = branchMap[key];
const line = meta.loc.start.line;
let i = 0;
branchArray.forEach(b => {
writer.println('BRDA:' + [line, key, i, b].join(','));
i += 1;
Object.entries(branches).forEach(([key, branchArray]) => {
const meta = branchMap[key];
const { line } = meta.loc.start;
branchArray.forEach((b, i) => {
writer.println('BRDA:' + [line, key, i, b].join(','));
});
});
});
writer.println('BRF:' + summary.branches.total);
writer.println('BRH:' + summary.branches.covered);
writer.println('end_of_record');
};
writer.println('BRF:' + summary.branches.total);
writer.println('BRH:' + summary.branches.covered);
writer.println('end_of_record');
}
LcovOnlyReport.prototype.onEnd = function() {
this.contentWriter.close();
};
onEnd() {
this.contentWriter.close();
}
}
module.exports = LcovOnlyReport;

@@ -0,1 +1,2 @@

'use strict';
/*

@@ -5,4 +6,6 @@ Copyright 2012-2015, Yahoo Inc.

*/
function NoneReport() {}
const { ReportBase } = require('istanbul-lib-report');
class NoneReport extends ReportBase {}
module.exports = NoneReport;

@@ -6,7 +6,51 @@ /*

'use strict';
const { ReportBase } = require('istanbul-lib-report');
function TeamcityReport(opts) {
opts = opts || {};
this.file = opts.file || null;
this.blockName = opts.blockName || 'Code Coverage Summary';
class TeamcityReport extends ReportBase {
constructor(opts) {
super();
opts = opts || {};
this.file = opts.file || null;
this.blockName = opts.blockName || 'Code Coverage Summary';
}
onStart(node, context) {
const metrics = node.getCoverageSummary();
const cw = context.writer.writeFile(this.file);
cw.println('');
cw.println("##teamcity[blockOpened name='" + this.blockName + "']");
//Statements Covered
cw.println(
lineForKey(metrics.statements.covered, 'CodeCoverageAbsBCovered')
);
cw.println(
lineForKey(metrics.statements.total, 'CodeCoverageAbsBTotal')
);
//Branches Covered
cw.println(
lineForKey(metrics.branches.covered, 'CodeCoverageAbsRCovered')
);
cw.println(lineForKey(metrics.branches.total, 'CodeCoverageAbsRTotal'));
//Functions Covered
cw.println(
lineForKey(metrics.functions.covered, 'CodeCoverageAbsMCovered')
);
cw.println(
lineForKey(metrics.functions.total, 'CodeCoverageAbsMTotal')
);
//Lines Covered
cw.println(
lineForKey(metrics.lines.covered, 'CodeCoverageAbsLCovered')
);
cw.println(lineForKey(metrics.lines.total, 'CodeCoverageAbsLTotal'));
cw.println("##teamcity[blockClosed name='" + this.blockName + "']");
cw.close();
}
}

@@ -24,33 +68,2 @@

TeamcityReport.prototype.onStart = function(node, context) {
const metrics = node.getCoverageSummary();
const cw = context.writer.writeFile(this.file);
cw.println('');
cw.println("##teamcity[blockOpened name='" + this.blockName + "']");
//Statements Covered
cw.println(
lineForKey(metrics.statements.covered, 'CodeCoverageAbsBCovered')
);
cw.println(lineForKey(metrics.statements.total, 'CodeCoverageAbsBTotal'));
//Branches Covered
cw.println(lineForKey(metrics.branches.covered, 'CodeCoverageAbsRCovered'));
cw.println(lineForKey(metrics.branches.total, 'CodeCoverageAbsRTotal'));
//Functions Covered
cw.println(
lineForKey(metrics.functions.covered, 'CodeCoverageAbsMCovered')
);
cw.println(lineForKey(metrics.functions.total, 'CodeCoverageAbsMTotal'));
//Lines Covered
cw.println(lineForKey(metrics.lines.covered, 'CodeCoverageAbsLCovered'));
cw.println(lineForKey(metrics.lines.total, 'CodeCoverageAbsLTotal'));
cw.println("##teamcity[blockClosed name='" + this.blockName + "']");
cw.close();
};
module.exports = TeamcityReport;

@@ -0,1 +1,2 @@

'use strict';
/*

@@ -5,11 +6,12 @@ Copyright 2012-2015, Yahoo Inc.

*/
const util = require('util');
const LcovOnly = require('../lcovonly');
function TextLcov(opts) {
opts.file = '-';
LcovOnly.call(this, opts);
class TextLcov extends LcovOnly {
constructor(opts) {
super(opts);
opts.file = '-';
}
}
util.inherits(TextLcov, LcovOnly);
module.exports = TextLcov;

@@ -6,6 +6,34 @@ /*

'use strict';
const { ReportBase } = require('istanbul-lib-report');
function TextSummaryReport(opts) {
opts = opts || {};
this.file = opts.file || null;
class TextSummaryReport extends ReportBase {
constructor(opts) {
super();
opts = opts || {};
this.file = opts.file || null;
}
onStart(node, context) {
const summary = node.getCoverageSummary();
const cw = context.writer.writeFile(this.file);
const printLine = function(key) {
const str = lineForKey(summary, key);
const clazz = context.classForPercent(key, summary[key].pct);
cw.println(cw.colorize(str, clazz));
};
cw.println('');
cw.println(
'=============================== Coverage summary ==============================='
);
printLine('statements');
printLine('branches');
printLine('functions');
printLine('lines');
cw.println(
'================================================================================'
);
cw.close();
}
}

@@ -35,25 +63,2 @@

TextSummaryReport.prototype.onStart = function(node, context) {
const summary = node.getCoverageSummary();
const cw = context.writer.writeFile(this.file);
const printLine = function(key) {
const str = lineForKey(summary, key);
const clazz = context.classForPercent(key, summary[key].pct);
cw.println(cw.colorize(str, clazz));
};
cw.println('');
cw.println(
'=============================== Coverage summary ==============================='
);
printLine('statements');
printLine('branches');
printLine('functions');
printLine('lines');
cw.println(
'================================================================================'
);
cw.close();
};
module.exports = TextSummaryReport;
/*
Copyright 2012-2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
Copyrights licensed under the New BSD License. See the accompanying LICENSE
file for terms.
*/
'use strict';
const { ReportBase } = require('istanbul-lib-report');
const PCT_COLS = 9;
const MISSING_COL = 18;
const NAME_COL = 4;
const PCT_COLS = 7;
const MISSING_COL = 17;
const TAB_SIZE = 1;
const DELIM = ' |';
const COL_DELIM = '-|';
const DELIM = ' | ';

@@ -31,13 +33,17 @@ function padding(num, ch) {

let fmtStr = '';
let fillStr;
const strlen = str.length;
if (remaining > 0) {
const strlen = str.length;
let fillStr;
if (remaining >= strlen) {
fillStr = padding(remaining - strlen);
fmtStr = right ? fillStr + str : str + fillStr;
} else {
fmtStr = str.substring(strlen - remaining);
fmtStr = '... ' + fmtStr.substring(4);
fillStr = '...';
const length = remaining - fillStr.length;
str = str.substring(strlen - length);
right = true;
}
fmtStr = right ? fillStr + str : str + fillStr;
}

@@ -56,2 +62,25 @@

function nodeMissing(node) {
if (node.isSummary()) {
return '';
}
const metrics = node.getCoverageSummary();
const isEmpty = metrics.isEmpty();
const lines = isEmpty ? 0 : metrics.lines.pct;
let missingLines;
const fileCoverage = node.getFileCoverage();
if (lines === 100) {
const branches = fileCoverage.getBranchCoverageByLine();
missingLines = Object.keys(branches).filter(
key => branches[key].coverage < 100
);
} else {
missingLines = fileCoverage.getUncoveredLines();
}
return missingLines.join(',');
}
function nodeName(node) {

@@ -71,18 +100,17 @@ return node.getRelativeName() || 'All files';

function findNameWidth(node, context) {
function nullDepthFor() {
return 0;
}
function findWidth(node, context, nodeExtractor, depthFor = nullDepthFor) {
let last = 0;
const compareWidth = function(node) {
const depth = depthFor(node);
const idealWidth = TAB_SIZE * depth + nodeName(node).length;
if (idealWidth > last) {
last = idealWidth;
}
};
function compareWidth(node) {
last = Math.max(
last,
TAB_SIZE * depthFor(node) + nodeExtractor(node).length
);
}
const visitor = {
onSummary(node) {
compareWidth(node);
},
onDetail(node) {
compareWidth(node);
}
onSummary: compareWidth,
onDetail: compareWidth
};

@@ -93,3 +121,3 @@ node.visit(context.getVisitor(visitor));

function makeLine(nameWidth) {
function makeLine(nameWidth, missingWidth) {
const name = padding(nameWidth, '-');

@@ -101,37 +129,20 @@ const pct = padding(PCT_COLS, '-');

elements.push(pct);
elements.push(padding(PCT_COLS + 1, '-'));
elements.push(pct);
elements.push(pct);
elements.push(pct);
elements.push(padding(MISSING_COL, '-'));
return elements.join(COL_DELIM) + COL_DELIM;
elements.push(padding(missingWidth, '-'));
return elements.join(DELIM.replace(/ /g, '-')) + '-';
}
function tableHeader(maxNameCols) {
function tableHeader(maxNameCols, missingWidth) {
const elements = [];
elements.push(formatName('File', maxNameCols, 0));
elements.push(formatPct('% Stmts'));
elements.push(formatPct('% Branch'));
elements.push(formatPct('% Branch', PCT_COLS + 1));
elements.push(formatPct('% Funcs'));
elements.push(formatPct('% Lines'));
elements.push(formatPct('Uncovered Line #s', MISSING_COL));
return elements.join(' |') + ' |';
elements.push(formatName('Uncovered Line #s', missingWidth));
return elements.join(DELIM) + ' ';
}
function missingLines(node, colorizer) {
const missingLines = node.isSummary()
? []
: node.getFileCoverage().getUncoveredLines();
return colorizer(formatPct(missingLines.join(','), MISSING_COL), 'low');
}
function missingBranches(node, colorizer) {
const branches = node.isSummary()
? {}
: node.getFileCoverage().getBranchCoverageByLine();
const missingLines = Object.keys(branches)
.filter(key => branches[key].coverage < 100)
.map(key => key);
return colorizer(formatPct(missingLines.join(','), MISSING_COL), 'medium');
}
function isFull(metrics) {

@@ -153,3 +164,4 @@ return (

skipEmpty,
skipFull
skipFull,
missingWidth
) {

@@ -183,64 +195,87 @@ const name = nodeName(node);

elements.push(colorize(formatPct(mm.statements), 'statements'));
elements.push(colorize(formatPct(mm.branches), 'branches'));
elements.push(colorize(formatPct(mm.branches, PCT_COLS + 1), 'branches'));
elements.push(colorize(formatPct(mm.functions), 'functions'));
elements.push(colorize(formatPct(mm.lines), 'lines'));
if (mm.lines === 100) {
elements.push(missingBranches(node, colorizer));
} else {
elements.push(missingLines(node, colorizer));
}
return elements.join(DELIM) + DELIM;
}
elements.push(
colorizer(
formatName(nodeMissing(node), missingWidth),
mm.lines === 100 ? 'medium' : 'low'
)
);
function TextReport(opts) {
opts = opts || {};
this.file = opts.file || null;
this.maxCols = opts.maxCols || 0;
this.cw = null;
this.skipEmpty = opts.skipEmpty;
this.skipFull = opts.skipFull;
return elements.join(DELIM) + ' ';
}
TextReport.prototype.onStart = function(root, context) {
const statsWidth = 4 * (PCT_COLS + 2) + MISSING_COL;
class TextReport extends ReportBase {
constructor(opts) {
super();
this.cw = context.writer.writeFile(this.file);
this.nameWidth = findNameWidth(root, context);
if (this.maxCols > 0) {
const maxRemaining = this.maxCols - statsWidth - 2;
if (this.nameWidth > maxRemaining) {
this.nameWidth = maxRemaining;
opts = opts || {};
const { maxCols } = opts;
this.file = opts.file || null;
this.maxCols = maxCols != null ? maxCols : process.stdout.columns || 80;
this.cw = null;
this.skipEmpty = opts.skipEmpty;
this.skipFull = opts.skipFull;
}
onStart(root, context) {
this.cw = context.writer.writeFile(this.file);
this.nameWidth = Math.max(
NAME_COL,
findWidth(root, context, nodeName, depthFor)
);
this.missingWidth = Math.max(
MISSING_COL,
findWidth(root, context, nodeMissing)
);
if (this.maxCols > 0) {
const pct_cols = DELIM.length + 4 * (PCT_COLS + DELIM.length) + 2;
const maxRemaining = this.maxCols - (pct_cols + MISSING_COL);
if (this.nameWidth > maxRemaining) {
this.nameWidth = maxRemaining;
this.missingWidth = MISSING_COL;
} else if (this.nameWidth < maxRemaining) {
const maxRemaining = this.maxCols - (this.nameWidth + pct_cols);
if (this.missingWidth > maxRemaining) {
this.missingWidth = maxRemaining;
}
}
}
const line = makeLine(this.nameWidth, this.missingWidth);
this.cw.println(line);
this.cw.println(tableHeader(this.nameWidth, this.missingWidth));
this.cw.println(line);
}
const line = makeLine(this.nameWidth);
this.cw.println(line);
this.cw.println(tableHeader(this.nameWidth));
this.cw.println(line);
};
TextReport.prototype.onSummary = function(node, context) {
const nodeDepth = depthFor(node);
const row = tableRow(
node,
context,
this.cw.colorize.bind(this.cw),
this.nameWidth,
nodeDepth,
this.skipEmpty,
this.skipFull
);
if (row) {
this.cw.println(row);
onSummary(node, context) {
const nodeDepth = depthFor(node);
const row = tableRow(
node,
context,
this.cw.colorize.bind(this.cw),
this.nameWidth,
nodeDepth,
this.skipEmpty,
this.skipFull,
this.missingWidth
);
if (row) {
this.cw.println(row);
}
}
};
TextReport.prototype.onDetail = function(node, context) {
return this.onSummary(node, context);
};
onDetail(node, context) {
return this.onSummary(node, context);
}
TextReport.prototype.onEnd = function() {
this.cw.println(makeLine(this.nameWidth));
this.cw.close();
};
onEnd() {
this.cw.println(makeLine(this.nameWidth, this.missingWidth));
this.cw.close();
}
}
module.exports = TextReport;
{
"name": "istanbul-reports",
"version": "2.2.6",
"version": "3.0.0-alpha.0",
"description": "istanbul reports",

@@ -12,3 +12,4 @@ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>",

"scripts": {
"test": "mocha --recursive"
"test": "nyc --nycrc-path=../../monorepo-per-package-nycrc.json mocha --recursive",
"prepare": "rollup --config lib/html-spa/rollup.config.js"
},

@@ -19,4 +20,19 @@ "dependencies": {

"devDependencies": {
"istanbul-lib-coverage": "^2.0.5",
"istanbul-lib-report": "^2.0.8"
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"chai": "^4.2.0",
"is-windows": "^1.0.2",
"istanbul-lib-coverage": "^3.0.0-alpha.0",
"istanbul-lib-report": "^3.0.0-alpha.0",
"mocha": "^6.1.4",
"nyc": "^14.1.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rollup": "^1.15.6",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.3",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^5.0.0"
},

@@ -36,6 +52,15 @@ "license": "BSD-3-Clause",

"homepage": "https://istanbul.js.org/",
"nyc": {
"exclude": [
"lib/html/assets/**",
"lib/html-spa/assets/**",
"lib/html-spa/src/**",
"lib/html-spa/rollup.config.js",
"test/**"
]
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"gitHead": "90e60cc47833bb780680f916488ca24f0be36ca2"
"gitHead": "2e885073a9398806c9b8763dd39418398182ca34"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc