From 2c2e54b61386aea7cfcb74c58baff15d3d498621 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Thu, 30 Aug 2018 13:01:13 -0400 Subject: [PATCH] Fix feedback --- lib/modules/coverage/contract_source.js | 6 ++---- lib/modules/coverage/index.js | 1 - lib/modules/coverage/source_map.js | 8 ++++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/modules/coverage/contract_source.js b/lib/modules/coverage/contract_source.js index 899a97c51..7bca32a0d 100644 --- a/lib/modules/coverage/contract_source.js +++ b/lib/modules/coverage/contract_source.js @@ -97,7 +97,7 @@ class ContractSource { } } - /*eslint complexity: ["error", 34]*/ + /*eslint complexity: ["error", 36]*/ generateCodeCoverage(trace) { if(!this.ast || !this.contractBytecode) throw new Error('Error generating coverage: solc output was not assigned'); @@ -198,8 +198,6 @@ class ContractSource { parent: node._parent }); - - //children = node.expression ? [node.expression] : []; markLocations = [location]; break; @@ -298,7 +296,7 @@ class ContractSource { trace.structLogs.forEach((step) => { step = bytecode[step.pc]; - if(!step.sourceMap || step.sourceMap == '' || step.sourceMap == SourceMap.empty()) return; + if(!step.sourceMap || step.sourceMap === '' || step.sourceMap === SourceMap.empty()) return; let sourceMapString = step.sourceMap.toString(this.id); var nodes = sourceMapToNodeType[sourceMapString]; diff --git a/lib/modules/coverage/index.js b/lib/modules/coverage/index.js index f7214e9d3..a9070a1d7 100644 --- a/lib/modules/coverage/index.js +++ b/lib/modules/coverage/index.js @@ -10,7 +10,6 @@ web3.extend({ methods: [{name: 'traceTransaction', call: 'debug_traceTransaction', params: 2}] }); - class CodeCoverage { constructor(embark, _options) { this.events = embark.events; diff --git a/lib/modules/coverage/source_map.js b/lib/modules/coverage/source_map.js index 119d69ea7..6795d0e41 100644 --- a/lib/modules/coverage/source_map.js +++ b/lib/modules/coverage/source_map.js @@ -1,6 +1,6 @@ class EmptySourceMap { static createRelativeTo(sourceMapString) { - if(sourceMapString == '') return EmptySourceMap; + if(sourceMapString === '') return EmptySourceMap; return new SourceMap(sourceMapString); } @@ -29,12 +29,12 @@ class SourceMap { } createRelativeTo(sourceMapString) { - if(sourceMapString == '' || sourceMapString == undefined) return EmptySourceMap; + if(!sourceMapString) return EmptySourceMap; let [offset, length, id, jump] = sourceMapString.split(":"); - offset = (offset == '') ? this.offset : parseInt(offset, 10); - id = (id == '' || id == undefined) ? this.id : parseInt(id, 10); + offset = (offset) ? parseInt(offset, 10) : this.offset; + id = (id) ? parseInt(id, 10) : this.id; length = parseInt(length, 10); return new SourceMap(offset, length, id, jump);