From 839db68571037f6fff8273aaade6ea0bd14ea8a5 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 16 May 2018 14:59:10 +0200 Subject: Fix TSLint rules --- packages/sol-cov/test/collect_coverage_entries_test.ts | 7 +++++-- packages/sol-cov/test/instructions_test.ts | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'packages/sol-cov/test') diff --git a/packages/sol-cov/test/collect_coverage_entries_test.ts b/packages/sol-cov/test/collect_coverage_entries_test.ts index c7b9d44b1..f60a57cb7 100644 --- a/packages/sol-cov/test/collect_coverage_entries_test.ts +++ b/packages/sol-cov/test/collect_coverage_entries_test.ts @@ -39,13 +39,15 @@ describe('Collect coverage entries', () => { const coverageEntries = collectCoverageEntries(simpleStorageContract); const fnIds = _.keys(coverageEntries.fnMap); expect(coverageEntries.fnMap[fnIds[0]].name).to.be.equal('set'); - expect(coverageEntries.fnMap[fnIds[0]].line).to.be.equal(5); + const setExpectedLineNumber = 5; + expect(coverageEntries.fnMap[fnIds[0]].line).to.be.equal(setExpectedLineNumber); const setFunction = `function set(uint x) { storedData = x; }`; expect(getRange(simpleStorageContract, coverageEntries.fnMap[fnIds[0]].loc)).to.be.equal(setFunction); expect(coverageEntries.fnMap[fnIds[1]].name).to.be.equal('get'); - expect(coverageEntries.fnMap[fnIds[1]].line).to.be.equal(8); + const getExpectedLineNumber = 8; + expect(coverageEntries.fnMap[fnIds[1]].line).to.be.equal(getExpectedLineNumber); const getFunction = `function get() constant returns (uint retVal) { return storedData; }`; @@ -121,6 +123,7 @@ describe('Collect coverage entries', () => { const branchDescriptions = _.values(coverageEntries.branchMap); const branchLines = _.map(branchDescriptions, branchDescription => branchDescription.line); + // tslint:disable-next-line:custom-no-magic-numbers expect(branchLines).to.be.deep.equal([94, 115, 119, 130, 151, 187]); const branchTypes = _.map(branchDescriptions, branchDescription => branchDescription.type); expect(branchTypes).to.be.deep.equal(['if', 'if', 'if', 'if', 'binary-expr', 'if']); diff --git a/packages/sol-cov/test/instructions_test.ts b/packages/sol-cov/test/instructions_test.ts index 195dfce2f..bb8fb5bf6 100644 --- a/packages/sol-cov/test/instructions_test.ts +++ b/packages/sol-cov/test/instructions_test.ts @@ -11,6 +11,7 @@ const expect = chai.expect; describe('instructions', () => { describe('#getPcToInstructionIndexMapping', () => { it('correctly maps pcs to instruction indexed', () => { + // tslint:disable-next-line:custom-no-magic-numbers const bytecode = new Uint8Array([constants.PUSH1, 42, constants.PUSH2, 1, 2, constants.TIMESTAMP]); const pcToInstruction = getPcToInstructionIndexMapping(bytecode); const expectedPcToInstruction = { '0': 0, '2': 1, '5': 2 }; -- cgit From cf7967e6296aac0a328143e92a22c5682541a576 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 17 May 2018 14:07:44 +0200 Subject: Disable magic number rule in more places where it isn't helping code readability --- packages/sol-cov/test/collect_coverage_entries_test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/sol-cov/test') diff --git a/packages/sol-cov/test/collect_coverage_entries_test.ts b/packages/sol-cov/test/collect_coverage_entries_test.ts index f60a57cb7..4263ed197 100644 --- a/packages/sol-cov/test/collect_coverage_entries_test.ts +++ b/packages/sol-cov/test/collect_coverage_entries_test.ts @@ -39,15 +39,15 @@ describe('Collect coverage entries', () => { const coverageEntries = collectCoverageEntries(simpleStorageContract); const fnIds = _.keys(coverageEntries.fnMap); expect(coverageEntries.fnMap[fnIds[0]].name).to.be.equal('set'); - const setExpectedLineNumber = 5; - expect(coverageEntries.fnMap[fnIds[0]].line).to.be.equal(setExpectedLineNumber); + // tslint:disable-next-line:custom-no-magic-numbers + expect(coverageEntries.fnMap[fnIds[0]].line).to.be.equal(5); const setFunction = `function set(uint x) { storedData = x; }`; expect(getRange(simpleStorageContract, coverageEntries.fnMap[fnIds[0]].loc)).to.be.equal(setFunction); expect(coverageEntries.fnMap[fnIds[1]].name).to.be.equal('get'); - const getExpectedLineNumber = 8; - expect(coverageEntries.fnMap[fnIds[1]].line).to.be.equal(getExpectedLineNumber); + // tslint:disable-next-line:custom-no-magic-numbers + expect(coverageEntries.fnMap[fnIds[1]].line).to.be.equal(8); const getFunction = `function get() constant returns (uint retVal) { return storedData; }`; -- cgit