npm imports working without location

pull/1398/head
Aniket-Engg 3 years ago committed by Aniket
parent d2184ccdd9
commit 9aaa913570
  1. 34
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx
  2. 5
      libs/remixd/src/services/slitherClient.ts

@ -201,22 +201,24 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
let column = 0 let column = 0
let row = 0 let row = 0
let fileName = currentFile let fileName = currentFile
if (item.sourceMap && item.sourceMap.length) { // There are issues with location for imported contract
location = { // which stops complete analysis including remix analyzer's
start: item.sourceMap[0].source_mapping.start, // if (item.sourceMap && item.sourceMap.length) {
length: item.sourceMap[0].source_mapping.length // location = {
} // start: item.sourceMap[0].source_mapping.start,
location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn( // length: item.sourceMap[0].source_mapping.length
location, // }
Object.keys(lastCompilationResult.sources).indexOf(item.sourceMap[0].source_mapping.filename_relative), // location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn(
lastCompilationSource.sources, // location,
lastCompilationResult.sources // Object.keys(lastCompilationResult.sources).indexOf(item.sourceMap[0].source_mapping.filename_relative),
) // lastCompilationSource.sources,
row = location.start.line // lastCompilationResult.sources
column = location.start.column // )
locationString = row + 1 + ':' + column + ':' // row = location.start.line
fileName = Object.keys(lastCompilationResult.contracts)[0] // column = location.start.column
} // locationString = row + 1 + ':' + column + ':'
// fileName = Object.keys(lastCompilationResult.contracts)[0]
// }
warningCount++ warningCount++
const msg = message(item.title, item.description, item.more, fileName, locationString) const msg = message(item.title, item.description, item.more, fileName, locationString)
const options = { const options = {

@ -127,9 +127,10 @@ export class SlitherClient extends PluginClient {
const solcRemaps = remaps ? `--solc-remaps "${remaps}"` : '' const solcRemaps = remaps ? `--solc-remaps "${remaps}"` : ''
const cmd: string = `slither ${filePath} ${solcArgs} ${solcRemaps} --json ${outputFile}` const cmd: string = `slither ${filePath} ${solcArgs} ${solcRemaps} --json ${outputFile}`
console.log('command--->', cmd)
console.log('\x1b[32m%s\x1b[0m', '[Slither Analysis]: Running Slither...') console.log('\x1b[32m%s\x1b[0m', '[Slither Analysis]: Running Slither...')
const child = spawn(cmd, options) // Added `stdio: 'ignore'` as for contract with NPM imports analysis which is exported in 'stderr'
// get too big and hangs the process. We process analysis from the report file only
const child = spawn(cmd, { cwd: this.currentSharedFolder, shell: true, stdio: 'ignore' })
const response = {} const response = {}
child.on('close', () => { child.on('close', () => {
const outputFileAbsPath: string = `${this.currentSharedFolder}/${outputFile}` const outputFileAbsPath: string = `${this.currentSharedFolder}/${outputFile}`

Loading…
Cancel
Save