istanbul-reports
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.2.0](https://github.com/istanbuljs/istanbuljs/compare/istanbul-reports@2.1.1...istanbul-reports@2.2.0) (2019-03-12) | ||
### Features | ||
* set medium colour to yellow ([#306](https://github.com/istanbuljs/istanbuljs/issues/306)) ([ed40be7](https://github.com/istanbuljs/istanbuljs/commit/ed40be7)) | ||
## [2.1.1](https://github.com/istanbuljs/istanbuljs/compare/istanbul-reports@2.1.0...istanbul-reports@2.1.1) (2019-02-14) | ||
@@ -8,0 +19,0 @@ |
@@ -5,8 +5,8 @@ /* | ||
*/ | ||
var path = require('path'); | ||
const path = require('path'); | ||
module.exports = { | ||
create: function(name, cfg) { | ||
create(name, cfg) { | ||
cfg = cfg || {}; | ||
var Cons; | ||
let Cons; | ||
try { | ||
@@ -13,0 +13,0 @@ Cons = require(path.join(__dirname, 'lib', name)); |
@@ -36,19 +36,19 @@ /* | ||
CloverReport.prototype.getTreeStats = function(node, context) { | ||
var state = { | ||
packages: 0, | ||
files: 0, | ||
classes: 0 | ||
const state = { | ||
packages: 0, | ||
files: 0, | ||
classes: 0 | ||
}; | ||
const visitor = { | ||
onSummary(node, state) { | ||
const metrics = node.getCoverageSummary(true); | ||
if (metrics) { | ||
state.packages += 1; | ||
} | ||
}, | ||
visitor = { | ||
onSummary: function(node, state) { | ||
var metrics = node.getCoverageSummary(true); | ||
if (metrics) { | ||
state.packages += 1; | ||
} | ||
}, | ||
onDetail: function(node, state) { | ||
state.classes += 1; | ||
state.files += 1; | ||
} | ||
}; | ||
onDetail(node, state) { | ||
state.classes += 1; | ||
state.files += 1; | ||
} | ||
}; | ||
node.visit(context.getVisitor(visitor), state); | ||
@@ -59,23 +59,22 @@ return state; | ||
CloverReport.prototype.writeRootStats = function(node, context) { | ||
var metrics = node.getCoverageSummary(), | ||
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 | ||
}, | ||
treeStats; | ||
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 | ||
}; | ||
@@ -93,4 +92,4 @@ this.cw.println('<?xml version="1.0" encoding="UTF-8"?>'); | ||
treeStats = this.getTreeStats(node, context); | ||
Object.keys(treeStats).forEach(function(k) { | ||
const treeStats = this.getTreeStats(node, context); | ||
Object.keys(treeStats).forEach(k => { | ||
attrs[k] = treeStats[k]; | ||
@@ -117,3 +116,3 @@ }); | ||
} | ||
var metrics = node.getCoverageSummary(true); | ||
const metrics = node.getCoverageSummary(true); | ||
if (!metrics) { | ||
@@ -137,7 +136,5 @@ return; | ||
CloverReport.prototype.onDetail = function(node) { | ||
var that = this, | ||
fileCoverage = node.getFileCoverage(), | ||
metrics = node.getCoverageSummary(), | ||
branchByLine = fileCoverage.getBranchCoverageByLine(), | ||
lines; | ||
const fileCoverage = node.getFileCoverage(); | ||
const metrics = node.getCoverageSummary(); | ||
const branchByLine = fileCoverage.getBranchCoverageByLine(); | ||
@@ -151,10 +148,10 @@ this.xml.openTag('file', { | ||
lines = fileCoverage.getLineCoverage(); | ||
Object.keys(lines).forEach(function(k) { | ||
var attrs = { | ||
num: k, | ||
count: lines[k], | ||
type: 'stmt' | ||
}, | ||
branchDetail = branchByLine[k]; | ||
const lines = fileCoverage.getLineCoverage(); | ||
Object.keys(lines).forEach(k => { | ||
const attrs = { | ||
num: k, | ||
count: lines[k], | ||
type: 'stmt' | ||
}; | ||
const branchDetail = branchByLine[k]; | ||
@@ -166,3 +163,3 @@ if (branchDetail) { | ||
} | ||
that.xml.inlineTag('line', attrs); | ||
this.xml.inlineTag('line', attrs); | ||
}); | ||
@@ -169,0 +166,0 @@ |
@@ -5,3 +5,3 @@ /* | ||
*/ | ||
var path = require('path'); | ||
const path = require('path'); | ||
function CoberturaReport(opts) { | ||
@@ -38,3 +38,3 @@ this.cw = null; | ||
CoberturaReport.prototype.writeRootStats = function(node) { | ||
var metrics = node.getCoverageSummary(); | ||
const metrics = node.getCoverageSummary(); | ||
this.cw.println('<?xml version="1.0" ?>'); | ||
@@ -65,3 +65,3 @@ this.cw.println( | ||
} | ||
var metrics = node.getCoverageSummary(true); | ||
const metrics = node.getCoverageSummary(true); | ||
if (!metrics) { | ||
@@ -87,8 +87,5 @@ return; | ||
CoberturaReport.prototype.onDetail = function(node) { | ||
var that = this, | ||
fileCoverage = node.getFileCoverage(), | ||
metrics = node.getCoverageSummary(), | ||
branchByLine = fileCoverage.getBranchCoverageByLine(), | ||
fnMap, | ||
lines; | ||
const fileCoverage = node.getFileCoverage(); | ||
const metrics = node.getCoverageSummary(); | ||
const branchByLine = fileCoverage.getBranchCoverageByLine(); | ||
@@ -103,19 +100,19 @@ this.xml.openTag('class', { | ||
this.xml.openTag('methods'); | ||
fnMap = fileCoverage.fnMap; | ||
Object.keys(fnMap).forEach(function(k) { | ||
var name = fnMap[k].name, | ||
hits = fileCoverage.f[k]; | ||
that.xml.openTag('method', { | ||
name: name, | ||
hits: hits, | ||
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 | ||
}); | ||
that.xml.openTag('lines'); | ||
this.xml.openTag('lines'); | ||
//Add the function definition line and hits so that jenkins cobertura plugin records method hits | ||
that.xml.inlineTag('line', { | ||
this.xml.inlineTag('line', { | ||
number: fnMap[k].decl.start.line, | ||
hits: hits | ||
hits | ||
}); | ||
that.xml.closeTag('lines'); | ||
that.xml.closeTag('method'); | ||
this.xml.closeTag('lines'); | ||
this.xml.closeTag('method'); | ||
}); | ||
@@ -125,10 +122,10 @@ this.xml.closeTag('methods'); | ||
this.xml.openTag('lines'); | ||
lines = fileCoverage.getLineCoverage(); | ||
Object.keys(lines).forEach(function(k) { | ||
var attrs = { | ||
number: k, | ||
hits: lines[k], | ||
branch: 'false' | ||
}, | ||
branchDetail = branchByLine[k]; | ||
const lines = fileCoverage.getLineCoverage(); | ||
Object.keys(lines).forEach(k => { | ||
const attrs = { | ||
number: k, | ||
hits: lines[k], | ||
branch: 'false' | ||
}; | ||
const branchDetail = branchByLine[k]; | ||
@@ -145,3 +142,3 @@ if (branchDetail) { | ||
} | ||
that.xml.inlineTag('line', attrs); | ||
this.xml.inlineTag('line', attrs); | ||
}); | ||
@@ -148,0 +145,0 @@ |
@@ -7,12 +7,12 @@ /* | ||
var InsertionText = require('./insertion-text'), | ||
lt = '\u0001', | ||
gt = '\u0002', | ||
RE_LT = /</g, | ||
RE_GT = />/g, | ||
RE_AMP = /&/g, | ||
// eslint-disable-next-line | ||
RE_lt = /\u0001/g, | ||
// eslint-disable-next-line | ||
RE_gt = /\u0002/g; | ||
const InsertionText = require('./insertion-text'); | ||
const lt = '\u0001'; | ||
const gt = '\u0002'; | ||
const RE_LT = /</g; | ||
const RE_GT = />/g; | ||
const RE_AMP = /&/g; | ||
// eslint-disable-next-line | ||
var RE_lt = /\u0001/g; | ||
// eslint-disable-next-line | ||
var RE_gt = /\u0002/g; | ||
@@ -34,8 +34,8 @@ function title(str) { | ||
function annotateLines(fileCoverage, structuredText) { | ||
var lineStats = fileCoverage.getLineCoverage(); | ||
const lineStats = fileCoverage.getLineCoverage(); | ||
if (!lineStats) { | ||
return; | ||
} | ||
Object.keys(lineStats).forEach(function(lineNumber) { | ||
var count = lineStats[lineNumber]; | ||
Object.keys(lineStats).forEach(lineNumber => { | ||
const count = lineStats[lineNumber]; | ||
if (structuredText[lineNumber]) { | ||
@@ -49,21 +49,21 @@ structuredText[lineNumber].covered = count > 0 ? 'yes' : 'no'; | ||
function annotateStatements(fileCoverage, structuredText) { | ||
var statementStats = fileCoverage.s, | ||
statementMeta = fileCoverage.statementMap; | ||
Object.keys(statementStats).forEach(function(stName) { | ||
var count = statementStats[stName], | ||
meta = statementMeta[stName], | ||
type = count > 0 ? 'yes' : 'no', | ||
startCol = meta.start.column, | ||
endCol = meta.end.column + 1, | ||
startLine = meta.start.line, | ||
endLine = meta.end.line, | ||
openSpan = | ||
lt + | ||
'span class="' + | ||
(meta.skip ? 'cstat-skip' : 'cstat-no') + | ||
'"' + | ||
title('statement not covered') + | ||
gt, | ||
closeSpan = lt + '/span' + gt, | ||
text; | ||
const statementStats = fileCoverage.s; | ||
const statementMeta = fileCoverage.statementMap; | ||
Object.keys(statementStats).forEach(stName => { | ||
const count = statementStats[stName]; | ||
const meta = statementMeta[stName]; | ||
const type = count > 0 ? 'yes' : 'no'; | ||
const startCol = meta.start.column; | ||
let endCol = meta.end.column + 1; | ||
const startLine = meta.start.line; | ||
const endLine = meta.end.line; | ||
const openSpan = | ||
lt + | ||
'span class="' + | ||
(meta.skip ? 'cstat-skip' : 'cstat-no') + | ||
'"' + | ||
title('statement not covered') + | ||
gt; | ||
const closeSpan = lt + '/span' + gt; | ||
let text; | ||
@@ -86,24 +86,24 @@ if (type === 'no' && structuredText[startLine]) { | ||
function annotateFunctions(fileCoverage, structuredText) { | ||
var fnStats = fileCoverage.f, | ||
fnMeta = fileCoverage.fnMap; | ||
const fnStats = fileCoverage.f; | ||
const fnMeta = fileCoverage.fnMap; | ||
if (!fnStats) { | ||
return; | ||
} | ||
Object.keys(fnStats).forEach(function(fName) { | ||
var count = fnStats[fName], | ||
meta = fnMeta[fName], | ||
type = count > 0 ? 'yes' : 'no', | ||
startCol = meta.decl.start.column, | ||
endCol = meta.decl.end.column + 1, | ||
startLine = meta.decl.start.line, | ||
endLine = meta.decl.end.line, | ||
openSpan = | ||
lt + | ||
'span class="' + | ||
(meta.skip ? 'fstat-skip' : 'fstat-no') + | ||
'"' + | ||
title('function not covered') + | ||
gt, | ||
closeSpan = lt + '/span' + gt, | ||
text; | ||
Object.keys(fnStats).forEach(fName => { | ||
const count = fnStats[fName]; | ||
const meta = fnMeta[fName]; | ||
const type = count > 0 ? 'yes' : 'no'; | ||
const startCol = meta.decl.start.column; | ||
let endCol = meta.decl.end.column + 1; | ||
const startLine = meta.decl.start.line; | ||
const endLine = meta.decl.end.line; | ||
const openSpan = | ||
lt + | ||
'span class="' + | ||
(meta.skip ? 'fstat-skip' : 'fstat-no') + | ||
'"' + | ||
title('function not covered') + | ||
gt; | ||
const closeSpan = lt + '/span' + gt; | ||
let text; | ||
@@ -126,4 +126,4 @@ if (type === 'no' && structuredText[startLine]) { | ||
function annotateBranches(fileCoverage, structuredText) { | ||
var branchStats = fileCoverage.b, | ||
branchMeta = fileCoverage.branchMap; | ||
const branchStats = fileCoverage.b; | ||
const branchMeta = fileCoverage.branchMap; | ||
if (!branchStats) { | ||
@@ -133,18 +133,16 @@ return; | ||
Object.keys(branchStats).forEach(function(branchName) { | ||
var branchArray = branchStats[branchName], | ||
sumCount = branchArray.reduce(function(p, n) { | ||
return p + n; | ||
}, 0), | ||
metaArray = branchMeta[branchName].locations, | ||
i, | ||
count, | ||
meta, | ||
startCol, | ||
endCol, | ||
startLine, | ||
endLine, | ||
openSpan, | ||
closeSpan, | ||
text; | ||
Object.keys(branchStats).forEach(branchName => { | ||
const branchArray = branchStats[branchName]; | ||
const sumCount = branchArray.reduce((p, n) => p + n, 0); | ||
const metaArray = branchMeta[branchName].locations; | ||
let i; | ||
let count; | ||
let meta; | ||
let startCol; | ||
let endCol; | ||
let startLine; | ||
let endLine; | ||
let openSpan; | ||
let closeSpan; | ||
let text; | ||
@@ -222,16 +220,17 @@ // only highlight if partial branches are missing or if there is a | ||
function annotateSourceCode(fileCoverage, sourceStore) { | ||
var codeArray, lineCoverageArray; | ||
let codeArray; | ||
let lineCoverageArray; | ||
try { | ||
var sourceText = sourceStore.getSource(fileCoverage.path), | ||
code = sourceText.split(/(?:\r?\n)|\r/), | ||
count = 0, | ||
structured = code.map(function(str) { | ||
count += 1; | ||
return { | ||
line: count, | ||
covered: 'neutral', | ||
hits: 0, | ||
text: new InsertionText(str, true) | ||
}; | ||
}); | ||
const sourceText = sourceStore.getSource(fileCoverage.path); | ||
const code = sourceText.split(/(?:\r?\n)|\r/); | ||
let count = 0; | ||
const structured = code.map(str => { | ||
count += 1; | ||
return { | ||
line: count, | ||
covered: 'neutral', | ||
hits: 0, | ||
text: new InsertionText(str, true) | ||
}; | ||
}); | ||
structured.unshift({ | ||
@@ -250,12 +249,10 @@ line: 0, | ||
codeArray = structured.map(function(item) { | ||
return customEscape(item.text.toString()) || ' '; | ||
}); | ||
codeArray = structured.map( | ||
item => customEscape(item.text.toString()) || ' ' | ||
); | ||
lineCoverageArray = structured.map(function(item) { | ||
return { | ||
covered: item.covered, | ||
hits: item.hits > 0 ? item.hits + 'x' : ' ' | ||
}; | ||
}); | ||
lineCoverageArray = structured.map(item => ({ | ||
covered: item.covered, | ||
hits: item.hits > 0 ? item.hits + 'x' : ' ' | ||
})); | ||
@@ -272,3 +269,3 @@ return { | ||
.split(/\r?\n/) | ||
.forEach(function(line) { | ||
.forEach(line => { | ||
codeArray.push(line); | ||
@@ -286,3 +283,3 @@ lineCoverageArray.push({ covered: 'no', hits: 0 }); | ||
module.exports = { | ||
annotateSourceCode: annotateSourceCode | ||
annotateSourceCode | ||
}; |
@@ -162,4 +162,4 @@ var addSorting = (function() { | ||
} | ||
cols = loadColumns(); | ||
loadData(cols); | ||
loadColumns(); | ||
loadData(); | ||
addSortIndicators(); | ||
@@ -166,0 +166,0 @@ enableUI(); |
@@ -7,5 +7,5 @@ /* | ||
handlebars.registerHelper('show_picture', function(opts) { | ||
var num = Number(opts.fn(this)), | ||
rest, | ||
cls = ''; | ||
let num = Number(opts.fn(this)); | ||
let rest; | ||
let cls = ''; | ||
if (isFinite(num)) { | ||
@@ -41,7 +41,6 @@ if (num === 100) { | ||
handlebars.registerHelper('show_ignores', function(metrics) { | ||
var statements = metrics.statements.skipped, | ||
functions = metrics.functions.skipped, | ||
branches = metrics.branches.skipped, | ||
result; | ||
handlebars.registerHelper('show_ignores', metrics => { | ||
const statements = metrics.statements.skipped; | ||
const functions = metrics.functions.skipped; | ||
const branches = metrics.branches.skipped; | ||
@@ -52,3 +51,3 @@ if (statements === 0 && functions === 0 && branches === 0) { | ||
result = []; | ||
const result = []; | ||
if (statements > 0) { | ||
@@ -72,7 +71,7 @@ result.push( | ||
handlebars.registerHelper('show_lines', function(opts) { | ||
var maxLines = Number(opts.fn(this)), | ||
i, | ||
array = []; | ||
const maxLines = Number(opts.fn(this)); | ||
let i; | ||
const array = []; | ||
for (i = 0; i < maxLines; i += 1) { | ||
var nextNum = i + 1; | ||
const nextNum = i + 1; | ||
array[i] = | ||
@@ -90,5 +89,5 @@ "<a name='L" + | ||
handlebars.registerHelper('show_line_execution_counts', function(context) { | ||
var array = []; | ||
context.forEach(function(data) { | ||
handlebars.registerHelper('show_line_execution_counts', context => { | ||
const array = []; | ||
context.forEach(data => { | ||
array.push( | ||
@@ -105,9 +104,9 @@ '<span class="cline-any cline-' + | ||
handlebars.registerHelper('show_code', function(context /*, opts */) { | ||
return context.join('\n'); | ||
}); | ||
handlebars.registerHelper('show_code', (context /*, opts */) => | ||
context.join('\n') | ||
); | ||
} | ||
module.exports = { | ||
registerHelpers: registerHelpers | ||
registerHelpers | ||
}; |
@@ -5,77 +5,77 @@ /* | ||
*/ | ||
var fs = require('fs'), | ||
path = require('path'), | ||
handlebars = require('handlebars').create(), | ||
annotator = require('./annotator'), | ||
helpers = require('./helpers'), | ||
templateFor = function(name) { | ||
return handlebars.compile( | ||
fs.readFileSync( | ||
path.resolve(__dirname, 'templates', name + '.txt'), | ||
'utf8' | ||
) | ||
); | ||
}, | ||
headerTemplate = templateFor('head'), | ||
footerTemplate = templateFor('foot'), | ||
detailTemplate = handlebars.compile( | ||
[ | ||
'<tr>', | ||
'<td class="line-count quiet">{{#show_lines}}{{maxLines}}{{/show_lines}}</td>', | ||
'<td class="line-coverage quiet">{{#show_line_execution_counts lineCoverage}}{{maxLines}}{{/show_line_execution_counts}}</td>', | ||
'<td class="text"><pre class="prettyprint lang-js">{{#show_code annotatedCode}}{{/show_code}}</pre></td>', | ||
'</tr>\n' | ||
].join('') | ||
), | ||
summaryTableHeader = [ | ||
'<div class="pad1">', | ||
'<table class="coverage-summary">', | ||
'<thead>', | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const handlebars = require('handlebars').create(); | ||
const annotator = require('./annotator'); | ||
const helpers = require('./helpers'); | ||
const templateFor = function(name) { | ||
return handlebars.compile( | ||
fs.readFileSync( | ||
path.resolve(__dirname, 'templates', name + '.txt'), | ||
'utf8' | ||
) | ||
); | ||
}; | ||
const headerTemplate = templateFor('head'); | ||
const footerTemplate = templateFor('foot'); | ||
const detailTemplate = handlebars.compile( | ||
[ | ||
'<tr>', | ||
' <th data-col="file" data-fmt="html" data-html="true" class="file">File</th>', | ||
' <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>', | ||
' <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>', | ||
' <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>', | ||
' <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>', | ||
' <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>', | ||
' <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>', | ||
' <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>', | ||
' <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>', | ||
' <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>', | ||
'</tr>', | ||
'</thead>', | ||
'<tbody>' | ||
].join('\n'), | ||
summaryLineTemplate = handlebars.compile( | ||
[ | ||
'<tr>', | ||
'<td class="file {{reportClasses.statements}}" data-value="{{file}}"><a href="{{output}}">{{file}}</a></td>', | ||
'<td data-value="{{metrics.statements.pct}}" class="pic {{reportClasses.statements}}"><div class="chart">{{#show_picture}}{{metrics.statements.pct}}{{/show_picture}}</div></td>', | ||
'<td data-value="{{metrics.statements.pct}}" class="pct {{reportClasses.statements}}">{{metrics.statements.pct}}%</td>', | ||
'<td data-value="{{metrics.statements.total}}" class="abs {{reportClasses.statements}}">{{metrics.statements.covered}}/{{metrics.statements.total}}</td>', | ||
'<td data-value="{{metrics.branches.pct}}" class="pct {{reportClasses.branches}}">{{metrics.branches.pct}}%</td>', | ||
'<td data-value="{{metrics.branches.total}}" class="abs {{reportClasses.branches}}">{{metrics.branches.covered}}/{{metrics.branches.total}}</td>', | ||
'<td data-value="{{metrics.functions.pct}}" class="pct {{reportClasses.functions}}">{{metrics.functions.pct}}%</td>', | ||
'<td data-value="{{metrics.functions.total}}" class="abs {{reportClasses.functions}}">{{metrics.functions.covered}}/{{metrics.functions.total}}</td>', | ||
'<td data-value="{{metrics.lines.pct}}" class="pct {{reportClasses.lines}}">{{metrics.lines.pct}}%</td>', | ||
'<td data-value="{{metrics.lines.total}}" class="abs {{reportClasses.lines}}">{{metrics.lines.covered}}/{{metrics.lines.total}}</td>', | ||
'</tr>\n' | ||
].join('\n\t') | ||
), | ||
summaryTableFooter = ['</tbody>', '</table>', '</div>'].join('\n'), | ||
emptyClasses = { | ||
statements: 'empty', | ||
lines: 'empty', | ||
functions: 'empty', | ||
branches: 'empty' | ||
}; | ||
'<td class="line-count quiet">{{#show_lines}}{{maxLines}}{{/show_lines}}</td>', | ||
'<td class="line-coverage quiet">{{#show_line_execution_counts lineCoverage}}{{maxLines}}{{/show_line_execution_counts}}</td>', | ||
'<td class="text"><pre class="prettyprint lang-js">{{#show_code annotatedCode}}{{/show_code}}</pre></td>', | ||
'</tr>\n' | ||
].join('') | ||
); | ||
const summaryTableHeader = [ | ||
'<div class="pad1">', | ||
'<table class="coverage-summary">', | ||
'<thead>', | ||
'<tr>', | ||
' <th data-col="file" data-fmt="html" data-html="true" class="file">File</th>', | ||
' <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>', | ||
' <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>', | ||
' <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>', | ||
' <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>', | ||
' <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>', | ||
' <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>', | ||
' <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>', | ||
' <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>', | ||
' <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>', | ||
'</tr>', | ||
'</thead>', | ||
'<tbody>' | ||
].join('\n'); | ||
const summaryLineTemplate = handlebars.compile( | ||
[ | ||
'<tr>', | ||
'<td class="file {{reportClasses.statements}}" data-value="{{file}}"><a href="{{output}}">{{file}}</a></td>', | ||
'<td data-value="{{metrics.statements.pct}}" class="pic {{reportClasses.statements}}"><div class="chart">{{#show_picture}}{{metrics.statements.pct}}{{/show_picture}}</div></td>', | ||
'<td data-value="{{metrics.statements.pct}}" class="pct {{reportClasses.statements}}">{{metrics.statements.pct}}%</td>', | ||
'<td data-value="{{metrics.statements.total}}" class="abs {{reportClasses.statements}}">{{metrics.statements.covered}}/{{metrics.statements.total}}</td>', | ||
'<td data-value="{{metrics.branches.pct}}" class="pct {{reportClasses.branches}}">{{metrics.branches.pct}}%</td>', | ||
'<td data-value="{{metrics.branches.total}}" class="abs {{reportClasses.branches}}">{{metrics.branches.covered}}/{{metrics.branches.total}}</td>', | ||
'<td data-value="{{metrics.functions.pct}}" class="pct {{reportClasses.functions}}">{{metrics.functions.pct}}%</td>', | ||
'<td data-value="{{metrics.functions.total}}" class="abs {{reportClasses.functions}}">{{metrics.functions.covered}}/{{metrics.functions.total}}</td>', | ||
'<td data-value="{{metrics.lines.pct}}" class="pct {{reportClasses.lines}}">{{metrics.lines.pct}}%</td>', | ||
'<td data-value="{{metrics.lines.total}}" class="abs {{reportClasses.lines}}">{{metrics.lines.covered}}/{{metrics.lines.total}}</td>', | ||
'</tr>\n' | ||
].join('\n\t') | ||
); | ||
const summaryTableFooter = ['</tbody>', '</table>', '</div>'].join('\n'); | ||
const emptyClasses = { | ||
statements: 'empty', | ||
lines: 'empty', | ||
functions: 'empty', | ||
branches: 'empty' | ||
}; | ||
helpers.registerHelpers(handlebars); | ||
var standardLinkMapper = { | ||
getPath: function(node) { | ||
const standardLinkMapper = { | ||
getPath(node) { | ||
if (typeof node === 'string') { | ||
return node; | ||
} | ||
var filePath = node.getQualifiedName(); | ||
let filePath = node.getQualifiedName(); | ||
if (node.isSummary()) { | ||
@@ -93,9 +93,9 @@ if (filePath !== '') { | ||
relativePath: function(source, target) { | ||
var targetPath = this.getPath(target), | ||
sourcePath = path.dirname(this.getPath(source)); | ||
relativePath(source, target) { | ||
const targetPath = this.getPath(target); | ||
const sourcePath = path.dirname(this.getPath(source)); | ||
return path.relative(sourcePath, targetPath); | ||
}, | ||
assetPath: function(node, name) { | ||
assetPath(node, name) { | ||
return this.relativePath(this.getPath(node), name); | ||
@@ -106,5 +106,4 @@ } | ||
function getBreadcrumbHtml(node, linkMapper) { | ||
var parent = node.getParent(), | ||
nodePath = [], | ||
linkPath; | ||
let parent = node.getParent(); | ||
const nodePath = []; | ||
@@ -116,5 +115,5 @@ while (parent) { | ||
linkPath = nodePath.map(function(ancestor) { | ||
var target = linkMapper.relativePath(node, ancestor), | ||
name = ancestor.getRelativeName() || 'All files'; | ||
const linkPath = nodePath.map(ancestor => { | ||
const target = linkMapper.relativePath(node, ancestor); | ||
const name = ancestor.getRelativeName() || 'All files'; | ||
return '<a href="' + target + '">' + name + '</a>'; | ||
@@ -130,3 +129,3 @@ }); | ||
function fillTemplate(node, templateData, linkMapper, context) { | ||
var summary = node.getCoverageSummary(); | ||
const summary = node.getCoverageSummary(); | ||
templateData.entity = node.getQualifiedName() || 'All files'; | ||
@@ -175,30 +174,27 @@ templateData.metrics = summary; | ||
HtmlReport.prototype.onStart = function(root, context) { | ||
var that = this, | ||
assetHeaders = { | ||
'.js': '/* eslint-disable */\n' | ||
}, | ||
copyAssets = function(subdir, writer) { | ||
var srcDir = path.resolve(__dirname, 'assets', subdir); | ||
fs.readdirSync(srcDir).forEach(function(f) { | ||
var resolvedSource = path.resolve(srcDir, f), | ||
resolvedDestination = '.', | ||
stat = fs.statSync(resolvedSource), | ||
dest; | ||
const assetHeaders = { | ||
'.js': '/* eslint-disable */\n' | ||
}; | ||
if (stat.isFile()) { | ||
dest = resolvedDestination + '/' + f; | ||
if (that.verbose) { | ||
console.log('Write asset: ' + dest); | ||
} | ||
writer.copyFile( | ||
resolvedSource, | ||
dest, | ||
assetHeaders[path.extname(f)] | ||
); | ||
['.', 'vendor'].forEach(subdir => { | ||
const writer = this.getWriter(context); | ||
const srcDir = path.resolve(__dirname, 'assets', subdir); | ||
fs.readdirSync(srcDir).forEach(f => { | ||
const resolvedSource = path.resolve(srcDir, f); | ||
const resolvedDestination = '.'; | ||
const stat = fs.statSync(resolvedSource); | ||
let dest; | ||
if (stat.isFile()) { | ||
dest = resolvedDestination + '/' + f; | ||
if (this.verbose) { | ||
console.log('Write asset: ' + dest); | ||
} | ||
}); | ||
}; | ||
['.', 'vendor'].forEach(function(subdir) { | ||
copyAssets(subdir, that.getWriter(context)); | ||
writer.copyFile( | ||
resolvedSource, | ||
dest, | ||
assetHeaders[path.extname(f)] | ||
); | ||
} | ||
}); | ||
}); | ||
@@ -208,3 +204,3 @@ }; | ||
function fixPct(metrics) { | ||
Object.keys(emptyClasses).forEach(function(key) { | ||
Object.keys(emptyClasses).forEach(key => { | ||
metrics[key].pct = 0; | ||
@@ -216,44 +212,40 @@ }); | ||
HtmlReport.prototype.onSummary = function(node, context) { | ||
var linkMapper = this.linkMapper, | ||
templateData = this.getTemplateData(), | ||
children = node.getChildren(), | ||
skipEmpty = this.skipEmpty, | ||
cw; | ||
const linkMapper = this.linkMapper; | ||
const templateData = this.getTemplateData(); | ||
const children = node.getChildren(); | ||
const skipEmpty = this.skipEmpty; | ||
fillTemplate(node, templateData, linkMapper, context); | ||
cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); | ||
const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); | ||
cw.write(headerTemplate(templateData)); | ||
cw.write(summaryTableHeader); | ||
children.forEach(function(child) { | ||
var metrics = child.getCoverageSummary(), | ||
isEmpty = metrics.isEmpty(); | ||
children.forEach(child => { | ||
const metrics = child.getCoverageSummary(); | ||
const isEmpty = metrics.isEmpty(); | ||
if (skipEmpty && isEmpty) { | ||
return; | ||
} | ||
var reportClasses = isEmpty | ||
? emptyClasses | ||
: { | ||
statements: context.classForPercent( | ||
'statements', | ||
metrics.statements.pct | ||
), | ||
lines: context.classForPercent( | ||
'lines', | ||
metrics.lines.pct | ||
), | ||
functions: context.classForPercent( | ||
'functions', | ||
metrics.functions.pct | ||
), | ||
branches: context.classForPercent( | ||
'branches', | ||
metrics.branches.pct | ||
) | ||
}, | ||
data = { | ||
metrics: isEmpty ? fixPct(metrics) : metrics, | ||
reportClasses: reportClasses, | ||
file: child.getRelativeName(), | ||
output: linkMapper.relativePath(node, child) | ||
}; | ||
const reportClasses = isEmpty | ||
? emptyClasses | ||
: { | ||
statements: context.classForPercent( | ||
'statements', | ||
metrics.statements.pct | ||
), | ||
lines: context.classForPercent('lines', metrics.lines.pct), | ||
functions: context.classForPercent( | ||
'functions', | ||
metrics.functions.pct | ||
), | ||
branches: context.classForPercent( | ||
'branches', | ||
metrics.branches.pct | ||
) | ||
}; | ||
const data = { | ||
metrics: isEmpty ? fixPct(metrics) : metrics, | ||
reportClasses, | ||
file: child.getRelativeName(), | ||
output: linkMapper.relativePath(node, child) | ||
}; | ||
cw.write(summaryLineTemplate(data) + '\n'); | ||
@@ -267,8 +259,7 @@ }); | ||
HtmlReport.prototype.onDetail = function(node, context) { | ||
var linkMapper = this.linkMapper, | ||
templateData = this.getTemplateData(), | ||
cw; | ||
const linkMapper = this.linkMapper; | ||
const templateData = this.getTemplateData(); | ||
fillTemplate(node, templateData, linkMapper, context); | ||
cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); | ||
const cw = this.getWriter(context).writeFile(linkMapper.getPath(node)); | ||
cw.write(headerTemplate(templateData)); | ||
@@ -275,0 +266,0 @@ cw.write('<pre><table class="coverage">\n'); |
@@ -14,10 +14,10 @@ /* | ||
var WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; | ||
const WHITE_RE = /[ \f\n\r\t\v\u00A0\u2028\u2029]/; | ||
InsertionText.prototype = { | ||
findFirstNonBlank: function() { | ||
var pos = -1, | ||
text = this.text, | ||
len = text.length, | ||
i; | ||
findFirstNonBlank() { | ||
let pos = -1; | ||
const text = this.text; | ||
const len = text.length; | ||
let i; | ||
for (i = 0; i < len; i += 1) { | ||
@@ -31,7 +31,7 @@ if (!text.charAt(i).match(WHITE_RE)) { | ||
}, | ||
findLastNonBlank: function() { | ||
var text = this.text, | ||
len = text.length, | ||
pos = text.length + 1, | ||
i; | ||
findLastNonBlank() { | ||
const text = this.text; | ||
const len = text.length; | ||
let pos = text.length + 1; | ||
let i; | ||
for (i = len - 1; i >= 0; i -= 1) { | ||
@@ -45,7 +45,7 @@ if (!text.charAt(i).match(WHITE_RE)) { | ||
}, | ||
originalLength: function() { | ||
originalLength() { | ||
return this.origLength; | ||
}, | ||
insertAt: function(col, str, insertBefore, consumeBlanks) { | ||
insertAt(col, str, insertBefore, consumeBlanks) { | ||
consumeBlanks = | ||
@@ -67,6 +67,6 @@ typeof consumeBlanks === 'undefined' | ||
var len = str.length, | ||
offset = this.findOffset(col, len, insertBefore), | ||
realPos = col + offset, | ||
text = this.text; | ||
const len = str.length; | ||
const offset = this.findOffset(col, len, insertBefore); | ||
const realPos = col + offset; | ||
const text = this.text; | ||
this.text = text.substring(0, realPos) + str + text.substring(realPos); | ||
@@ -76,7 +76,7 @@ return this; | ||
findOffset: function(pos, len, insertBefore) { | ||
var offsets = this.offsets, | ||
offsetObj, | ||
cumulativeOffset = 0, | ||
i; | ||
findOffset(pos, len, insertBefore) { | ||
const offsets = this.offsets; | ||
let offsetObj; | ||
let cumulativeOffset = 0; | ||
let i; | ||
@@ -98,3 +98,3 @@ for (i = 0; i < offsets.length; i += 1) { | ||
} else { | ||
offsets.splice(i, 0, { pos: pos, len: len }); | ||
offsets.splice(i, 0, { pos, len }); | ||
} | ||
@@ -104,3 +104,3 @@ return cumulativeOffset; | ||
wrap: function(startPos, startText, endPos, endText, consumeBlanks) { | ||
wrap(startPos, startText, endPos, endText, consumeBlanks) { | ||
this.insertAt(startPos, startText, true, consumeBlanks); | ||
@@ -111,7 +111,7 @@ this.insertAt(endPos, endText, false, consumeBlanks); | ||
wrapLine: function(startText, endText) { | ||
wrapLine(startText, endText) { | ||
this.wrap(0, startText, this.originalLength(), endText); | ||
}, | ||
toString: function() { | ||
toString() { | ||
return this.text; | ||
@@ -118,0 +118,0 @@ } |
@@ -19,3 +19,3 @@ /* | ||
JsonSummaryReport.prototype.writeSummary = function(filePath, sc) { | ||
var cw = this.contentWriter; | ||
const cw = this.contentWriter; | ||
if (this.first) { | ||
@@ -44,3 +44,3 @@ this.first = false; | ||
JsonSummaryReport.prototype.onEnd = function() { | ||
var cw = this.contentWriter; | ||
const cw = this.contentWriter; | ||
cw.println('}'); | ||
@@ -47,0 +47,0 @@ cw.close(); |
@@ -18,5 +18,5 @@ /* | ||
JsonReport.prototype.onDetail = function(node) { | ||
var fc = node.getFileCoverage(), | ||
key = fc.path, | ||
cw = this.contentWriter; | ||
const fc = node.getFileCoverage(); | ||
const key = fc.path; | ||
const cw = this.contentWriter; | ||
@@ -35,3 +35,3 @@ if (this.first) { | ||
JsonReport.prototype.onEnd = function() { | ||
var cw = this.contentWriter; | ||
const cw = this.contentWriter; | ||
cw.println('}'); | ||
@@ -38,0 +38,0 @@ cw.close(); |
@@ -5,4 +5,4 @@ /* | ||
*/ | ||
var LcovOnlyReport = require('../lcovonly'), | ||
HtmlReport = require('../html'); | ||
const LcovOnlyReport = require('../lcovonly'); | ||
const HtmlReport = require('../html'); | ||
@@ -14,14 +14,13 @@ function LcovReport() { | ||
['Start', 'End', 'Summary', 'SummaryEnd', 'Detail'].forEach(function(what) { | ||
var meth = 'on' + what; | ||
LcovReport.prototype[meth] = function() { | ||
var args = Array.prototype.slice.call(arguments), | ||
lcov = this.lcov, | ||
html = this.html; | ||
['Start', 'End', 'Summary', 'SummaryEnd', 'Detail'].forEach(what => { | ||
const meth = 'on' + what; | ||
LcovReport.prototype[meth] = function(...args) { | ||
const lcov = this.lcov; | ||
const html = this.html; | ||
if (lcov[meth]) { | ||
lcov[meth].apply(lcov, args); | ||
lcov[meth](...args); | ||
} | ||
if (html[meth]) { | ||
html[meth].apply(html, args); | ||
html[meth](...args); | ||
} | ||
@@ -28,0 +27,0 @@ }; |
@@ -17,10 +17,10 @@ /* | ||
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(); | ||
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(); | ||
@@ -30,4 +30,4 @@ writer.println('TN:'); //no test name | ||
Object.keys(functionMap).forEach(function(key) { | ||
var meta = functionMap[key]; | ||
Object.keys(functionMap).forEach(key => { | ||
const meta = functionMap[key]; | ||
writer.println('FN:' + [meta.decl.start.line, meta.name].join(',')); | ||
@@ -38,10 +38,10 @@ }); | ||
Object.keys(functionMap).forEach(function(key) { | ||
var stats = functions[key], | ||
meta = functionMap[key]; | ||
Object.keys(functionMap).forEach(key => { | ||
const stats = functions[key]; | ||
const meta = functionMap[key]; | ||
writer.println('FNDA:' + [stats, meta.name].join(',')); | ||
}); | ||
Object.keys(lines).forEach(function(key) { | ||
var stat = lines[key]; | ||
Object.keys(lines).forEach(key => { | ||
const stat = lines[key]; | ||
writer.println('DA:' + [key, stat].join(',')); | ||
@@ -52,8 +52,8 @@ }); | ||
Object.keys(branches).forEach(function(key) { | ||
var branchArray = branches[key], | ||
meta = branchMap[key], | ||
line = meta.loc.start.line, | ||
i = 0; | ||
branchArray.forEach(function(b) { | ||
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(',')); | ||
@@ -60,0 +60,0 @@ i += 1; |
@@ -24,6 +24,5 @@ /* | ||
TeamcityReport.prototype.onStart = function(node, context) { | ||
var metrics = node.getCoverageSummary(), | ||
cw; | ||
const metrics = node.getCoverageSummary(); | ||
const cw = context.writer.writeFile(this.file); | ||
cw = context.writer.writeFile(this.file); | ||
cw.println(''); | ||
@@ -30,0 +29,0 @@ cw.println("##teamcity[blockOpened name='" + this.blockName + "']"); |
@@ -5,4 +5,4 @@ /* | ||
*/ | ||
var util = require('util'), | ||
LcovOnly = require('../lcovonly'); | ||
const util = require('util'); | ||
const LcovOnly = require('../lcovonly'); | ||
@@ -9,0 +9,0 @@ function TextLcov(opts) { |
@@ -13,5 +13,3 @@ /* | ||
function lineForKey(summary, key) { | ||
var metrics = summary[key], | ||
skipped, | ||
result; | ||
const metrics = summary[key]; | ||
@@ -22,3 +20,3 @@ key = key.substring(0, 1).toUpperCase() + key.substring(1); | ||
} | ||
result = [ | ||
const result = [ | ||
key, | ||
@@ -31,5 +29,5 @@ ':', | ||
].join(' '); | ||
skipped = metrics.skipped; | ||
const skipped = metrics.skipped; | ||
if (skipped > 0) { | ||
result += ', ' + skipped + ' ignored'; | ||
return result + ', ' + skipped + ' ignored'; | ||
} | ||
@@ -40,11 +38,10 @@ return result; | ||
TextSummaryReport.prototype.onStart = function(node, context) { | ||
var summary = node.getCoverageSummary(), | ||
cw, | ||
printLine = function(key) { | ||
var str = lineForKey(summary, key), | ||
clazz = context.classForPercent(key, summary[key].pct); | ||
cw.println(cw.colorize(str, clazz)); | ||
}; | ||
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 = context.writer.writeFile(this.file); | ||
cw.println(''); | ||
@@ -51,0 +48,0 @@ cw.println( |
@@ -7,11 +7,11 @@ /* | ||
var PCT_COLS = 9, | ||
MISSING_COL = 18, | ||
TAB_SIZE = 1, | ||
DELIM = ' |', | ||
COL_DELIM = '-|'; | ||
const PCT_COLS = 9; | ||
const MISSING_COL = 18; | ||
const TAB_SIZE = 1; | ||
const DELIM = ' |'; | ||
const COL_DELIM = '-|'; | ||
function padding(num, ch) { | ||
var str = '', | ||
i; | ||
let str = ''; | ||
let i; | ||
ch = ch || ' '; | ||
@@ -28,8 +28,8 @@ for (i = 0; i < num; i += 1) { | ||
var leadingSpaces = tabs * TAB_SIZE, | ||
remaining = width - leadingSpaces, | ||
leader = padding(leadingSpaces), | ||
fmtStr = '', | ||
fillStr, | ||
strlen = str.length; | ||
const leadingSpaces = tabs * TAB_SIZE; | ||
const remaining = width - leadingSpaces; | ||
const leader = padding(leadingSpaces); | ||
let fmtStr = ''; | ||
let fillStr; | ||
const strlen = str.length; | ||
@@ -62,3 +62,3 @@ if (remaining > 0) { | ||
function depthFor(node) { | ||
var ret = 0; | ||
let ret = 0; | ||
node = node.getParent(); | ||
@@ -73,18 +73,18 @@ while (node) { | ||
function findNameWidth(node, context) { | ||
var last = 0, | ||
compareWidth = function(node) { | ||
var depth = depthFor(node), | ||
idealWidth = TAB_SIZE * depth + nodeName(node).length; | ||
if (idealWidth > last) { | ||
last = idealWidth; | ||
} | ||
let last = 0; | ||
const compareWidth = function(node) { | ||
const depth = depthFor(node); | ||
const idealWidth = TAB_SIZE * depth + nodeName(node).length; | ||
if (idealWidth > last) { | ||
last = idealWidth; | ||
} | ||
}; | ||
const visitor = { | ||
onSummary(node) { | ||
compareWidth(node); | ||
}, | ||
visitor = { | ||
onSummary: function(node) { | ||
compareWidth(node); | ||
}, | ||
onDetail: function(node) { | ||
compareWidth(node); | ||
} | ||
}; | ||
onDetail(node) { | ||
compareWidth(node); | ||
} | ||
}; | ||
node.visit(context.getVisitor(visitor)); | ||
@@ -95,5 +95,5 @@ return last; | ||
function makeLine(nameWidth) { | ||
var name = padding(nameWidth, '-'), | ||
pct = padding(PCT_COLS, '-'), | ||
elements = []; | ||
const name = padding(nameWidth, '-'); | ||
const pct = padding(PCT_COLS, '-'); | ||
const elements = []; | ||
@@ -110,3 +110,3 @@ elements.push(name); | ||
function tableHeader(maxNameCols) { | ||
var elements = []; | ||
const elements = []; | ||
elements.push(formatName('File', maxNameCols, 0)); | ||
@@ -122,3 +122,3 @@ elements.push(formatPct('% Stmts')); | ||
function missingLines(node, colorizer) { | ||
var missingLines = node.isSummary() | ||
const missingLines = node.isSummary() | ||
? [] | ||
@@ -130,12 +130,8 @@ : node.getFileCoverage().getUncoveredLines(); | ||
function missingBranches(node, colorizer) { | ||
var branches = node.isSummary() | ||
? {} | ||
: node.getFileCoverage().getBranchCoverageByLine(), | ||
missingLines = Object.keys(branches) | ||
.filter(function(key) { | ||
return branches[key].coverage < 100; | ||
}) | ||
.map(function(key) { | ||
return key; | ||
}); | ||
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'); | ||
@@ -162,5 +158,5 @@ } | ||
) { | ||
var name = nodeName(node), | ||
metrics = node.getCoverageSummary(), | ||
isEmpty = metrics.isEmpty(); | ||
const name = nodeName(node); | ||
const metrics = node.getCoverageSummary(); | ||
const isEmpty = metrics.isEmpty(); | ||
if (skipEmpty && isEmpty) { | ||
@@ -173,16 +169,16 @@ return ''; | ||
var mm = { | ||
statements: isEmpty ? 0 : metrics.statements.pct, | ||
branches: isEmpty ? 0 : metrics.branches.pct, | ||
functions: isEmpty ? 0 : metrics.functions.pct, | ||
lines: isEmpty ? 0 : metrics.lines.pct | ||
}, | ||
colorize = isEmpty | ||
? function(str) { | ||
return str; | ||
} | ||
: function(str, key) { | ||
return colorizer(str, context.classForPercent(key, mm[key])); | ||
}, | ||
elements = []; | ||
const mm = { | ||
statements: isEmpty ? 0 : metrics.statements.pct, | ||
branches: isEmpty ? 0 : metrics.branches.pct, | ||
functions: isEmpty ? 0 : metrics.functions.pct, | ||
lines: isEmpty ? 0 : metrics.lines.pct | ||
}; | ||
const colorize = isEmpty | ||
? function(str) { | ||
return str; | ||
} | ||
: function(str, key) { | ||
return colorizer(str, context.classForPercent(key, mm[key])); | ||
}; | ||
const elements = []; | ||
@@ -212,5 +208,3 @@ elements.push(colorize(formatName(name, maxNameCols, level), 'statements')); | ||
TextReport.prototype.onStart = function(root, context) { | ||
var line, | ||
statsWidth = 4 * (PCT_COLS + 2) + MISSING_COL, | ||
maxRemaining; | ||
const statsWidth = 4 * (PCT_COLS + 2) + MISSING_COL; | ||
@@ -220,3 +214,3 @@ this.cw = context.writer.writeFile(this.file); | ||
if (this.maxCols > 0) { | ||
maxRemaining = this.maxCols - statsWidth - 2; | ||
const maxRemaining = this.maxCols - statsWidth - 2; | ||
if (this.nameWidth > maxRemaining) { | ||
@@ -226,3 +220,3 @@ this.nameWidth = maxRemaining; | ||
} | ||
line = makeLine(this.nameWidth); | ||
const line = makeLine(this.nameWidth); | ||
this.cw.println(line); | ||
@@ -234,4 +228,4 @@ this.cw.println(tableHeader(this.nameWidth)); | ||
TextReport.prototype.onSummary = function(node, context) { | ||
var nodeDepth = depthFor(node); | ||
var row = tableRow( | ||
const nodeDepth = depthFor(node); | ||
const row = tableRow( | ||
node, | ||
@@ -238,0 +232,0 @@ context, |
{ | ||
"name": "istanbul-reports", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "istanbul reports", | ||
@@ -18,4 +18,4 @@ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>", | ||
"devDependencies": { | ||
"istanbul-lib-coverage": "^2.0.3", | ||
"istanbul-lib-report": "^2.0.4" | ||
"istanbul-lib-coverage": "^2.0.4", | ||
"istanbul-lib-report": "^2.0.5" | ||
}, | ||
@@ -34,7 +34,7 @@ "license": "BSD-3-Clause", | ||
}, | ||
"homepage": "https://github.com/istanbuljs/istanbuljs", | ||
"homepage": "https://istanbul.js.org/", | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"gitHead": "c02990692153f87670b3d59ba21a19bcf6fb8e51" | ||
"gitHead": "c81b051d83217947dfd97d8d06532bd5013e98c3" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93673
1978