npm imports working without location

pull/5370/head
Aniket-Engg 3 years ago committed by Aniket
parent 0255459813
commit a4f0ee2c19
  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 row = 0
let fileName = currentFile
if (item.sourceMap && item.sourceMap.length) {
location = {
start: item.sourceMap[0].source_mapping.start,
length: item.sourceMap[0].source_mapping.length
}
location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn(
location,
Object.keys(lastCompilationResult.sources).indexOf(item.sourceMap[0].source_mapping.filename_relative),
lastCompilationSource.sources,
lastCompilationResult.sources
)
row = location.start.line
column = location.start.column
locationString = row + 1 + ':' + column + ':'
fileName = Object.keys(lastCompilationResult.contracts)[0]
}
// There are issues with location for imported contract
// which stops complete analysis including remix analyzer's
// if (item.sourceMap && item.sourceMap.length) {
// location = {
// start: item.sourceMap[0].source_mapping.start,
// length: item.sourceMap[0].source_mapping.length
// }
// location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn(
// location,
// Object.keys(lastCompilationResult.sources).indexOf(item.sourceMap[0].source_mapping.filename_relative),
// lastCompilationSource.sources,
// lastCompilationResult.sources
// )
// row = location.start.line
// column = location.start.column
// locationString = row + 1 + ':' + column + ':'
// fileName = Object.keys(lastCompilationResult.contracts)[0]
// }
warningCount++
const msg = message(item.title, item.description, item.more, fileName, locationString)
const options = {

@ -127,9 +127,10 @@ export class SlitherClient extends PluginClient {
const solcRemaps = remaps ? `--solc-remaps "${remaps}"` : ''
const cmd: string = `slither ${filePath} ${solcArgs} ${solcRemaps} --json ${outputFile}`
console.log('command--->', cmd)
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 = {}
child.on('close', () => {
const outputFileAbsPath: string = `${this.currentSharedFolder}/${outputFile}`

Loading…
Cancel
Save