linting fix

pull/5370/head
aniket-engg 4 years ago committed by Aniket
parent 7dc46caa27
commit c6f6241605
  1. 22
      libs/remixd/src/services/slitherClient.ts

@ -1,3 +1,5 @@
/* eslint dot-notation: "off" */
import * as WS from 'ws' // eslint-disable-line import * as WS from 'ws' // eslint-disable-line
import { PluginClient } from '@remixproject/plugin' import { PluginClient } from '@remixproject/plugin'
import { existsSync, readFileSync } from 'fs' import { existsSync, readFileSync } from 'fs'
@ -24,8 +26,8 @@ export class SlitherClient extends PluginClient {
transform (detectors) { transform (detectors) {
const standardReport = [] const standardReport = []
for (let e of detectors) { for (const e of detectors) {
let obj = {} const obj = {}
obj['description'] = e['description'] obj['description'] = e['description']
obj['title'] = e.check obj['title'] = e.check
obj['confidence'] = e.confidence obj['confidence'] = e.confidence
@ -66,20 +68,10 @@ export class SlitherClient extends PluginClient {
const solcArgs = optimizeOption || evmOption ? `--solc-args '${optimizeOption}${evmOption}'` : '' const solcArgs = optimizeOption || evmOption ? `--solc-args '${optimizeOption}${evmOption}'` : ''
const cmd = `slither ${filePath} ${solcArgs} --json ${outputFile}` const cmd = `slither ${filePath} ${solcArgs} --json ${outputFile}`
const child = spawn(cmd, options) const child = spawn(cmd, options)
let result = '' const response = {}
let error = ''
let response = {}
child.stdout.on('data', (data) => {
const msg = `[Slither Analysis]: ${data.toString()}`
console.log('\x1b[32m%s\x1b[0m', msg)
result += msg + '\n'
})
child.stderr.on('data', (err) => {
error += `[Slither Analysis]: ${err.toString()}`
})
child.on('close', () => { child.on('close', () => {
const outputFileAbsPath = `${this.currentSharedFolder}/${outputFile}` const outputFileAbsPath = `${this.currentSharedFolder}/${outputFile}`
if (existsSync (outputFileAbsPath)) { if (existsSync(outputFileAbsPath)) {
let report = readFileSync(outputFileAbsPath, 'utf8') let report = readFileSync(outputFileAbsPath, 'utf8')
report = JSON.parse(report) report = JSON.parse(report)
if (report['success']) { if (report['success']) {
@ -87,7 +79,7 @@ export class SlitherClient extends PluginClient {
if (!report['results'] || !report['results'].detectors || !report['results'].detectors.length) { if (!report['results'] || !report['results'].detectors || !report['results'].detectors.length) {
response['count'] = 0 response['count'] = 0
} else { } else {
const { detectors } = report['results'] const { detectors } = report['results']
response['count'] = detectors.length response['count'] = detectors.length
response['data'] = this.transform(detectors) response['data'] = this.transform(detectors)
} }

Loading…
Cancel
Save