Address feedback

This commit is contained in:
Andre Medeiros 2018-08-10 10:40:58 -04:00 committed by Iuri Matias
parent 0b183c0280
commit f2939ae91b
4 changed files with 10 additions and 17 deletions

View File

@ -2,22 +2,18 @@ const SourceMap = require('./source_map');
class ContractSource {
constructor(file, body) {
let self = this;
this.file = file;
this.body = body;
this.lineLengths = body.split("\n").map((line) => { return line.length; });
this.lineCount = this.lineLengths.length;
this.lineOffsets = [];
this.lineLengths.forEach((length, line) => {
if(line == 0) {
this.lineOffsets[0] = 0;
return;
}
// +1 here factors in newline characters.
this.lineOffsets[line] = this.lineOffsets[line-1] + this.lineLengths[line-1] + 1;
});
this.lineOffsets = this.lineLengths.reduce((sum, _elt, i) => {
sum[i] = (i == 0) ? 0 : self.lineLengths[i-1] + sum[i-1] + 1;
return sum;
}, []);
this.contracts = {};
}

View File

@ -31,11 +31,10 @@ class CodeCoverage {
}
compileSolc(input) {
var sources = {};
Object.keys(input.sources).forEach((path) => {
sources[path] = input.sources[path].content;
});
var sources = Object.keys(input.sources).reduce((sum, elm, _i) => {
sum[elm] = input.sources[elm].content;
return sum;
}, {});
this.contractSources = new ContractSources(sources);
}

View File

@ -108,7 +108,6 @@ class Solidity {
}
}
//self.plugins.emitAndRunActionsForEvent('contracts:compiled:solc', output);
self.events.emit('contracts:compiled:solc', output);
callback(null, output);

View File

@ -193,7 +193,6 @@ contract x {
var trace = JSON.parse(loadFixture('geth-debugtrace-output-h-5.json'));
var coverage = cs.generateCodeCoverage(trace);
// dumpToFile(coverage, '/tmp/coverage.json');
done();
});