aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpacien2018-10-19 10:14:25 +0200
committerpacien2018-10-19 10:14:25 +0200
commita72b1853dda333956c00c7cd4d96161f195d84e5 (patch)
tree18cc8bc4c439242689f05b8d9a3c66d52f627e94 /src
parente23180d4d6d6a697666aa8378ee45cb5f1c39e72 (diff)
downloadjacoco-viewer-a72b1853dda333956c00c7cd4d96161f195d84e5.tar.gz
Add line coverage counter bubble
Diffstat (limited to 'src')
-rw-r--r--src/CoverageListing.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/CoverageListing.js b/src/CoverageListing.js
index 6b5bc6d..72a5ea8 100644
--- a/src/CoverageListing.js
+++ b/src/CoverageListing.js
@@ -65,6 +65,13 @@ export class CoverageListing extends Component {
65 .then(content => this.setState({ listingContent: content })); 65 .then(content => this.setState({ listingContent: content }));
66 } 66 }
67 67
68 _lineCoverageString(coverage) {
69 const instructionCount = parseInt(coverage.ci) + parseInt(coverage.mi);
70 const branchCount = parseInt(coverage.cb) + parseInt(coverage.mb);
71 return coverage.ci + '/' + instructionCount + ' instructions covered, ' +
72 coverage.cb + '/' + branchCount + ' branches covered';
73 }
74
68 _renderNone() { 75 _renderNone() {
69 return (<div>No source file provided.</div>); 76 return (<div>No source file provided.</div>);
70 } 77 }
@@ -76,10 +83,15 @@ export class CoverageListing extends Component {
76 _renderLine(lineContent, lineNumber) { 83 _renderLine(lineContent, lineNumber) {
77 if (!(lineNumber in this.state.coverageMap)) 84 if (!(lineNumber in this.state.coverageMap))
78 return (<li key={lineNumber}><pre>{lineContent}</pre></li>); 85 return (<li key={lineNumber}><pre>{lineContent}</pre></li>);
79 86
80 const coverage = this.state.coverageMap[lineNumber]; 87 const coverage = this.state.coverageMap[lineNumber];
81 const wellCovered = parseInt(coverage.mi) === 0 && parseInt(coverage.mb) === 0; 88 const wellCovered = parseInt(coverage.mi) === 0 && parseInt(coverage.mb) === 0;
82 return (<li key={lineNumber} well-covered={wellCovered.toString()}><pre>{lineContent}</pre></li>); 89
90 return (
91 <li key={lineNumber} well-covered={wellCovered.toString()} title={this._lineCoverageString(coverage)}>
92 <pre>{lineContent}</pre>
93 </li>
94 );
83 } 95 }
84 96
85 _renderListing() { 97 _renderListing() {