From e3a94d54e30fb17fa833b3c95d6e9ae30eeb04b3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 16 Dec 2019 19:14:15 -0500 Subject: [PATCH] update remix-analyzer syntax to use const, let and this --- remix-analyzer/index.js | 2 +- remix-analyzer/src/solidity-analyzer/index.js | 23 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/remix-analyzer/index.js b/remix-analyzer/index.js index 01345200d8..539f26dd35 100644 --- a/remix-analyzer/index.js +++ b/remix-analyzer/index.js @@ -1,4 +1,4 @@ -var CodeAnalysis = require('./src/solidity-analyzer') +const CodeAnalysis = require('./src/solidity-analyzer') module.exports = { CodeAnalysis: CodeAnalysis diff --git a/remix-analyzer/src/solidity-analyzer/index.js b/remix-analyzer/src/solidity-analyzer/index.js index 8f3083d712..7eb5e7cdcd 100644 --- a/remix-analyzer/src/solidity-analyzer/index.js +++ b/remix-analyzer/src/solidity-analyzer/index.js @@ -1,14 +1,13 @@ 'use strict' -var AstWalker = require('remix-lib').AstWalker -var list = require('./modules/list') +const AstWalker = require('remix-lib').AstWalker +const list = require('./modules/list') function staticAnalysisRunner () { } staticAnalysisRunner.prototype.run = function (compilationResult, toRun, callback) { - var self = this - var modules = toRun.map(function (i) { - var m = self.modules()[i] + const modules = toRun.map((i) => { + const m = this.modules()[i] return { 'name': m.name, 'mod': new m.Module() } }) @@ -16,12 +15,12 @@ staticAnalysisRunner.prototype.run = function (compilationResult, toRun, callbac } staticAnalysisRunner.prototype.runWithModuleList = function (compilationResult, modules, callback) { - var reports = [] + let reports = [] // Also provide convenience analysis via the AST walker. - var walker = new AstWalker() - for (var k in compilationResult.sources) { - walker.walk(compilationResult.sources[k].legacyAST, {'*': function (node) { - modules.map(function (item, i) { + const walker = new AstWalker() + for (let k in compilationResult.sources) { + walker.walk(compilationResult.sources[k].legacyAST, {'*': (node) => { + modules.map((item, i) => { if (item.mod.visit !== undefined) { try { item.mod.visit(node) @@ -38,8 +37,8 @@ staticAnalysisRunner.prototype.runWithModuleList = function (compilationResult, // Here, modules can just collect the results from the AST walk, // but also perform new analysis. - reports = reports.concat(modules.map(function (item, i) { - var report = null + reports = reports.concat(modules.map((item, i) => { + let report = null try { report = item.mod.report(compilationResult) } catch (e) {