Merge pull request #97 from sc-forks/lint-022

Lint
pull/100/head
c-g-e-w-e-k-e- 7 years ago committed by GitHub
commit 7c0a6e9ee3
  1. 1
      .eslintrc
  2. 6
      lib/app.js
  3. 2
      lib/parse.js
  4. 12
      test/app.js
  5. 43
      test/assert.js
  6. 2
      test/conditional.js
  7. 1
      test/return.js
  8. 4
      test/statements.js
  9. 2
      test/util/mockTruffle.js
  10. 11
      test/util/util.js
  11. 2
      test/util/vm.js
  12. 1
      test/zeppelin.js

@ -32,6 +32,7 @@
"objectsInObjects": false,
"arraysInObjects": false
}],
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }],
"object-curly-newline": ["error", { "minProperties": 1 }],
"object-property-newline": ["error"],
"prefer-template": [0],

@ -68,7 +68,7 @@ class App {
// Load config if present, accomodate common windows naming.
let truffleConfig;
shell.test('-e', `${this.workingDir}/truffle.js`)
? truffleConfig = reqCwd.silent(`${this.workingDir}/truffle.js`)
: truffleConfig = reqCwd.silent(`${this.workingDir}/truffle-config.js`);
@ -142,11 +142,11 @@ class App {
const options = this.testrpcOptions || defaultRpcOptions;
const npm = './node_modules/.bin/testrpc-sc';
const yarn = './node_modules/ethereumjs-testrpc-sc/build/cli.node.js';
shell.test('-e', yarn)
? command = `${yarn} `
: command = `${npm} `;
// Launch
this.testrpcProcess = childprocess.exec(command + options, null, (err, stdout, stderr) => {
if (err) {

@ -1,4 +1,4 @@
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }] */
/**
* Methods in this file walk the AST and call the instrumenter

@ -60,7 +60,7 @@ describe('app', () => {
const testConfig = Object.assign({}, config);
testConfig.testrpcOptions = `--account="${privateKey},${balance}" --port 8777`;
testConfig.dir = './mock',
testConfig.dir = './mock';
testConfig.norpc = false;
testConfig.port = 8777;
@ -79,7 +79,7 @@ describe('app', () => {
const testConfig = Object.assign({}, config);
testConfig.testCommand = 'mocha --timeout 5000 > /dev/null 2>&1';
testConfig.dir = './mock',
testConfig.dir = './mock';
testConfig.norpc = false;
testConfig.port = 8888;
@ -98,7 +98,7 @@ describe('app', () => {
const testConfig = Object.assign({}, config);
testConfig.testCommand = 'node ../test/util/mockTestCommand.js';
testConfig.dir = './mock',
testConfig.dir = './mock';
testConfig.norpc = false;
testConfig.port = 8888;
@ -118,7 +118,7 @@ describe('app', () => {
const testConfig = Object.assign({}, config);
testConfig.dir = './mock',
testConfig.dir = './mock';
testConfig.norpc = false;
testConfig.port = 8889;
@ -159,7 +159,7 @@ describe('app', () => {
};`;
const testConfig = Object.assign({}, config);
testConfig.dir = './mock',
testConfig.dir = './mock';
testConfig.norpc = false;
testConfig.port = 8555; // Manually inspect that port is actually set to 8999
@ -209,7 +209,7 @@ describe('app', () => {
collectGarbage();
});
it('project uses truffle-config.js: should generate coverage, cleanup and exit(0)', () => {
it('project uses truffle-config.js: should generate coverage, cleanup and exit(0)', () => {
// Directory should be clean
assert(pathExists('./coverage') === false, 'should start without: coverage');
assert(pathExists('./coverage.json') === false, 'should start without: coverage.json');

@ -84,27 +84,26 @@ describe('asserts and requires', () => {
});
it('should cover multi-line require statements as if they are if statements when they fail', done => {
const contract = util.getCode('assert/RequireMultiline.sol');
const info = getInstrumentedVersion(contract, filePath);
const coverage = new CoverageMap();
coverage.addContract(info, filePath);
vm.execute(info.contract, 'a', [true, true, false]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {
5: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1],
});
assert.deepEqual(mapping[filePath].s, {
1: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
const contract = util.getCode('assert/RequireMultiline.sol');
const info = getInstrumentedVersion(contract, filePath);
const coverage = new CoverageMap();
coverage.addContract(info, filePath);
vm.execute(info.contract, 'a', [true, true, false]).then(events => {
const mapping = coverage.generate(events, pathPrefix);
assert.deepEqual(mapping[filePath].l, {
5: 1,
});
assert.deepEqual(mapping[filePath].b, {
1: [0, 1],
});
assert.deepEqual(mapping[filePath].s, {
1: 1,
});
assert.deepEqual(mapping[filePath].f, {
1: 1,
});
done();
}).catch(done);
});
});

@ -199,5 +199,5 @@ describe('conditional statements', () => {
assert.deepEqual(mapping[filePath].f, {1: 1});
done();
}).catch(done);
});*/
}); */
});

@ -5,7 +5,6 @@ const getInstrumentedVersion = require('./../lib/instrumentSolidity.js');
const util = require('./util/util.js');
describe('return statements', () => {
it('should compile after instrumenting function that returns true', () => {
const contract = util.getCode('return/return.sol');
const info = getInstrumentedVersion(contract, 'test.sol');

@ -60,8 +60,8 @@ describe('generic statements', () => {
util.report(output.errors);
assert.fail('WRONG'); // We shouldn't hit this.
} catch (err) {
(err.actual === 'WRONG') ? assert(false): assert(true);
}
(err.actual === 'WRONG') ? assert(false) : assert(true);
}
});
it('should cover a statement following a close brace', done => {

@ -15,7 +15,7 @@ const shell = require('shelljs');
module.exports.install = function install(contract, test, config, _trufflejs, _trufflejsName) {
const configjs = `module.exports = ${JSON.stringify(config)}`;
const contractLocation = `./${contract}`;
const trufflejsName = _trufflejsName || 'truffle.js';
const trufflejsName = _trufflejsName || 'truffle.js';
// Mock migrations
const initialMigration = `

@ -11,12 +11,11 @@ module.exports.getCode = function getCode(_path) {
};
module.exports.report = function report(errors) {
if (errors){
if (errors) {
errors.forEach(error => {
if (error.indexOf('Warning') === -1) {
throw new Error(`Instrumented solidity invalid: ${errors}`);
}
if (error.indexOf('Warning') === -1) {
throw new Error(`Instrumented solidity invalid: ${errors}`);
}
});
}
}
};

@ -123,7 +123,7 @@ function callMethod(vm, abi, address, functionName, args) {
events.pop();
shell.rm('./allFiredEvents');
resolve(events);
} catch (err) {
} catch (e) {
resolve([]);
}
});

@ -5,7 +5,6 @@ const getInstrumentedVersion = require('./../lib/instrumentSolidity.js');
const util = require('./util/util.js');
describe('Battery test of production contracts: OpenZeppelin', () => {
it('should compile after instrumenting zeppelin-solidity/Bounty.sol', () => {
const bounty = getInstrumentedVersion(util.getCode('zeppelin/Bounty.sol'), 'Bounty.sol');
const ownable = getInstrumentedVersion(util.getCode('zeppelin/Ownable.sol'), 'Ownable.sol');

Loading…
Cancel
Save