Merge branch 'master' into mg-compile-btn-text

pull/2257/head
Miladinho 3 years ago committed by GitHub
commit fec3e79b00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts
  2. 8
      libs/remix-analyzer/src/solidity-analyzer/index.ts
  3. 13
      libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts
  4. 13
      libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts
  5. 7
      libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.4.24.ts
  6. 7
      libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.5.0.ts
  7. 4
      libs/remix-ui/checkbox/src/lib/remix-ui-checkbox.tsx
  8. 311
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -30,6 +30,27 @@ module.exports = {
}, },
'Static Analysis': function (browser: NightwatchBrowser) { 'Static Analysis': function (browser: NightwatchBrowser) {
runTests(browser) runTests(browser)
},
'run analysis and filter results': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('filePanel')
.click('*[data-id="treeViewLitreeViewItemcontracts"]')
.click('*[data-id="treeViewLitreeViewItemcontracts/2_Owner.sol"]')
.clickLaunchIcon('solidity')
.pause(10000)
.clickLaunchIcon('solidityStaticAnalysis')
.waitForElementPresent('#staticanalysisresult .warning', 5000)
.assert.containsText('#verticalIconsKindsolidityStaticAnalysis .remixui_status', '1') // Check warning count
.verify.elementPresent('input[name="showLibWarnings"]')
.verify.elementNotPresent('input[name="showLibWarnings"]:checked')
.verify.elementPresent('label[id="headingshowLibWarnings"]')
.click('label[id="headingshowLibWarnings"]')
.pause(1000)
.assert.containsText('#verticalIconsKindsolidityStaticAnalysis .remixui_status', '382')
.click('label[id="headingshowLibWarnings"]')
.pause(1000)
.assert.containsText('#verticalIconsKindsolidityStaticAnalysis .remixui_status', '1')
.end()
} }
} }
@ -47,14 +68,12 @@ function runTests (browser: NightwatchBrowser) {
'TooMuchGas.() : Variables have very similar names "test" and "test1".', 'TooMuchGas.() : Variables have very similar names "test" and "test1".',
'TooMuchGas.() : Variables have very similar names "test" and "test1".'], 'TooMuchGas.() : Variables have very similar names "test" and "test1".'],
'#staticanalysisresult .warning', '#staticanalysisresult .warning',
browser, function () { browser
browser.end()
}
) )
}) })
} }
function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser, callback: VoidFunction) { function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser) {
browser.execute(function (selector) { browser.execute(function (selector) {
const items = document.querySelectorAll(selector) const items = document.querySelectorAll(selector)
const ret = [] const ret = []
@ -68,6 +87,5 @@ function listSelectorContains (textsToFind: string[], selector: string, browser:
console.log('testing `' + result.value[k] + '` against `' + textsToFind[k] + '`') console.log('testing `' + result.value[k] + '` against `' + textsToFind[k] + '`')
browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true) browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true)
} }
callback()
}) })
} }

@ -15,13 +15,13 @@ export default class staticAnalysisRunner {
* @param toRun module indexes (compiled from remix IDE) * @param toRun module indexes (compiled from remix IDE)
* @param callback callback * @param callback callback
*/ */
run (compilationResult: CompilationResult, toRun: number[], callback: ((reports: AnalysisReport[]) => void)): void { run (compilationResult: CompilationResult, toRun: number[]): AnalysisReport[] {
const modules: ModuleObj[] = toRun.map((i) => { const modules: ModuleObj[] = toRun.map((i) => {
const Module = this.modules()[i] const Module = this.modules()[i]
const m = new Module() const m = new Module()
return { name: m.name, mod: m } return { name: m.name, mod: m }
}) })
this.runWithModuleList(compilationResult, modules, callback) return this.runWithModuleList(compilationResult, modules)
} }
/** /**
@ -30,7 +30,7 @@ export default class staticAnalysisRunner {
* @param modules analysis module * @param modules analysis module
* @param callback callback * @param callback callback
*/ */
runWithModuleList (compilationResult: CompilationResult, modules: ModuleObj[], callback: ((reports: AnalysisReport[]) => void)): void { runWithModuleList (compilationResult: CompilationResult, modules: ModuleObj[]): AnalysisReport[] {
let reports: AnalysisReport[] = [] let reports: AnalysisReport[] = []
// Also provide convenience analysis via the AST walker. // Also provide convenience analysis via the AST walker.
const walker = new AstWalker() const walker = new AstWalker()
@ -64,7 +64,7 @@ export default class staticAnalysisRunner {
} }
return { name: item.name, report: report } return { name: item.name, report: report }
})) }))
callback(reports) return reports
} }
/** /**

@ -814,12 +814,11 @@ test('Integration test forLoopIteratesOverDynamicArray module', function (t: tes
function runModuleOnFiles (Module: any, t: test.Test, cb: ((fname: string, report: AnalysisReportObj[]) => void)): void { function runModuleOnFiles (Module: any, t: test.Test, cb: ((fname: string, report: AnalysisReportObj[]) => void)): void {
const statRunner: StatRunner = new StatRunner() const statRunner: StatRunner = new StatRunner()
testFiles.forEach((fileName: string) => { testFiles.forEach((fileName: string) => {
statRunner.runWithModuleList(compilationResults[fileName], [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => { const reports = statRunner.runWithModuleList(compilationResults[fileName], [{ name: new Module().name, mod: new Module() }])
let report: AnalysisReportObj[] = reports[0].report let report: AnalysisReportObj[] = reports[0].report
if (report.some((x: AnalysisReportObj) => x.warning.includes('INTERNAL ERROR'))) { if (report.some((x: AnalysisReportObj) => x.warning.includes('INTERNAL ERROR'))) {
t.comment('Error while executing Module: ' + JSON.stringify(report)) t.comment('Error while executing Module: ' + JSON.stringify(report))
} }
cb(fileName, report) cb(fileName, report)
})
}) })
} }

@ -816,12 +816,11 @@ test('Integration test forLoopIteratesOverDynamicArray module', function (t: tes
function runModuleOnFiles (Module: any, t: test.Test, cb: ((fname: string, report: AnalysisReportObj[]) => void)): void { function runModuleOnFiles (Module: any, t: test.Test, cb: ((fname: string, report: AnalysisReportObj[]) => void)): void {
const statRunner: StatRunner = new StatRunner() const statRunner: StatRunner = new StatRunner()
testFiles.forEach((fileName: string) => { testFiles.forEach((fileName: string) => {
statRunner.runWithModuleList(compilationResults[fileName], [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => { const reports = statRunner.runWithModuleList(compilationResults[fileName], [{ name: new Module().name, mod: new Module() }])
let report: AnalysisReportObj[] = reports[0].report let report: AnalysisReportObj[] = reports[0].report
if (report.some((x: AnalysisReportObj) => x['warning'].includes('INTERNAL ERROR'))) { if (report.some((x: AnalysisReportObj) => x['warning'].includes('INTERNAL ERROR'))) {
t.comment('Error while executing Module: ' + JSON.stringify(report)) t.comment('Error while executing Module: ' + JSON.stringify(report))
} }
cb(fileName, report) cb(fileName, report)
})
}) })
} }

@ -31,10 +31,9 @@ test('staticAnalysisIssues.functionParameterPassingError', function (t) {
const statRunner: StatRunner = new StatRunner() const statRunner: StatRunner = new StatRunner()
t.doesNotThrow(() => { t.doesNotThrow(() => {
statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => {}) statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module()}])
}, 'Analysis should not throw') }, 'Analysis should not throw')
statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => { const reports = statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module()}])
t.ok(!reports.some((mod: AnalysisReport) => mod.report.some((rep: AnalysisReportObj) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors')) t.ok(!reports.some((mod: AnalysisReport) => mod.report.some((rep: AnalysisReportObj) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors'))
})
}) })

@ -31,10 +31,9 @@ test('staticAnalysisIssues.functionParameterPassingError', function (t) {
const statRunner: StatRunner = new StatRunner() const statRunner: StatRunner = new StatRunner()
t.doesNotThrow(() => { t.doesNotThrow(() => {
statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => {}) statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }])
}, 'Analysis should not throw') }, 'Analysis should not throw')
statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }], (reports: AnalysisReport[]) => { const reports = statRunner.runWithModuleList(res, [{ name: new Module().name, mod: new Module() }])
t.ok(!reports.some((mod: AnalysisReport) => mod.report.some((rep: AnalysisReportObj) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors')) t.ok(!reports.some((mod: AnalysisReport) => mod.report.some((rep: AnalysisReportObj) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors'))
})
}) })

@ -12,6 +12,7 @@ export interface RemixUiCheckboxProps {
id?: string id?: string
itemName?: string itemName?: string
categoryId?: string categoryId?: string
title?: string
visibility?: string visibility?: string
display?: string display?: string
} }
@ -26,11 +27,12 @@ export const RemixUiCheckbox = ({
onChange, onChange,
itemName, itemName,
categoryId, categoryId,
title,
visibility, visibility,
display = 'flex' display = 'flex'
}: RemixUiCheckboxProps) => { }: RemixUiCheckboxProps) => {
return ( return (
<div className="listenOnNetwork_2A0YE0 custom-control custom-checkbox" style={{ display: display, alignItems: 'center', visibility: visibility } as CSSProperties } onClick={onClick}> <div className="listenOnNetwork_2A0YE0 custom-control custom-checkbox" title={title} style={{ display: display, alignItems: 'center', visibility: visibility } as CSSProperties } onClick={onClick}>
<input <input
id={id} id={id}
type={inputType} type={inputType}

@ -1,4 +1,4 @@
import React, { useEffect, useState, useReducer } from 'react' // eslint-disable-line import React, { useEffect, useState, useReducer, useRef } from 'react' // eslint-disable-line
import Button from './Button/StaticAnalyserButton' // eslint-disable-line import Button from './Button/StaticAnalyserButton' // eslint-disable-line
import { util } from '@remix-project/remix-lib' import { util } from '@remix-project/remix-lib'
import _ from 'lodash' import _ from 'lodash'
@ -64,10 +64,12 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
const [autoRun, setAutoRun] = useState(true) const [autoRun, setAutoRun] = useState(true)
const [slitherEnabled, setSlitherEnabled] = useState(false) const [slitherEnabled, setSlitherEnabled] = useState(false)
const [showSlither, setShowSlither] = useState(false) const [showSlither, setShowSlither] = useState(false)
let [showLibsWarning, setShowLibsWarning] = useState(false) // eslint-disable-line prefer-const
const [categoryIndex, setCategoryIndex] = useState(groupedModuleIndex(groupedModules)) const [categoryIndex, setCategoryIndex] = useState(groupedModuleIndex(groupedModules))
const warningContainer = React.useRef(null)
const [warningState, setWarningState] = useState({}) const [warningState, setWarningState] = useState({})
const warningContainer = useRef(null)
const allWarnings = useRef({})
const [state, dispatch] = useReducer(analysisReducer, initialState) const [state, dispatch] = useReducer(analysisReducer, initialState)
useEffect(() => { useEffect(() => {
@ -76,9 +78,12 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
useEffect(() => { useEffect(() => {
setWarningState({}) setWarningState({})
const runAnalysis = async () => {
await run(state.data, state.source, state.file)
}
if (autoRun) { if (autoRun) {
if (state.data !== null) { if (state.data !== null) {
run(state.data, state.source, state.file) runAnalysis().catch(console.error);
} }
} else { } else {
props.event.trigger('staticAnaysisWarning', []) props.event.trigger('staticAnaysisWarning', [])
@ -131,6 +136,30 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
) )
} }
const filterWarnings = () => {
let newWarningState = {}
let newWarningCount = 0
if (showLibsWarning) {
for (const category in allWarnings.current)
newWarningCount = newWarningCount + allWarnings.current[category].length
newWarningState = allWarnings.current
}
else {
for (const category in allWarnings.current) {
const warnings = allWarnings.current[category]
newWarningState[category] = []
for (const warning of warnings) {
if (!warning.options.isLibrary) {
newWarningCount++
newWarningState[category].push(warning)
}
}
}
}
props.event.trigger('staticAnaysisWarning', [newWarningCount])
setWarningState(newWarningState)
}
const showWarnings = (warningMessage, groupByKey) => { const showWarnings = (warningMessage, groupByKey) => {
const resultArray = [] const resultArray = []
warningMessage.map(x => { warningMessage.map(x => {
@ -149,143 +178,149 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
} }
const groupedCategory = groupBy(resultArray, groupByKey) const groupedCategory = groupBy(resultArray, groupByKey)
setWarningState(groupedCategory) allWarnings.current = groupedCategory
filterWarnings()
} }
const run = (lastCompilationResult, lastCompilationSource, currentFile) => { const run = async (lastCompilationResult, lastCompilationSource, currentFile) => {
if (state.data !== null) { if (state.data !== null) {
if (lastCompilationResult && (categoryIndex.length > 0 || slitherEnabled)) { if (lastCompilationResult && (categoryIndex.length > 0 || slitherEnabled)) {
let warningCount = 0
const warningMessage = [] const warningMessage = []
const warningErrors = [] const warningErrors = []
// Remix Analysis // Remix Analysis
_paq.push(['trackEvent', 'solidityStaticAnalyzer', 'analyzeWithRemixAnalyzer']) _paq.push(['trackEvent', 'solidityStaticAnalyzer', 'analyzeWithRemixAnalyzer'])
runner.run(lastCompilationResult, categoryIndex, results => { const results = runner.run(lastCompilationResult, categoryIndex)
results.map((result) => { for (const result of results) {
let moduleName let moduleName
Object.keys(groupedModules).map(key => { Object.keys(groupedModules).map(key => {
groupedModules[key].forEach(el => { groupedModules[key].forEach(el => {
if (el.name === result.name) { if (el.name === result.name) {
moduleName = groupedModules[key][0].categoryDisplayName moduleName = groupedModules[key][0].categoryDisplayName
}
})
})
result.report.map((item) => {
let location: any = {}
let locationString = 'not available'
let column = 0
let row = 0
let fileName = currentFile
if (item.location) {
const split = item.location.split(':')
const file = split[2]
location = {
start: parseInt(split[0]),
length: parseInt(split[1])
}
location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn(
location,
parseInt(file),
lastCompilationSource.sources,
lastCompilationResult.sources
)
row = location.start.line
column = location.start.column
locationString = row + 1 + ':' + column + ':'
fileName = Object.keys(lastCompilationResult.sources)[file]
}
warningCount++
const msg = message(result.name, item.warning, item.more, fileName, locationString)
const options = {
type: 'warning',
useSpan: true,
errFile: fileName,
fileName,
errLine: row,
errCol: column,
item: item,
name: result.name,
locationString,
more: item.more,
location: location
} }
warningErrors.push(options)
warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName })
}) })
}) })
// Slither Analysis for (const item of result.report) {
if (slitherEnabled) { let location: any = {}
props.analysisModule.call('solidity', 'getCompilerState').then((compilerState) => { let locationString = 'not available'
const { currentVersion, optimize, evmVersion } = compilerState let column = 0
props.analysisModule.call('terminal', 'log', { type: 'info', value: '[Slither Analysis]: Running...' }) let row = 0
_paq.push(['trackEvent', 'solidityStaticAnalyzer', 'analyzeWithSlither']) let fileName = currentFile
props.analysisModule.call('slither', 'analyse', state.file, { currentVersion, optimize, evmVersion }).then(async (result) => { let isLibrary = false
if (result.status) {
props.analysisModule.call('terminal', 'log', { type: 'info', value: `[Slither Analysis]: Analysis Completed!! ${result.count} warnings found.` })
const report = result.data
for (const item of report) {
let location: any = {}
let locationString = 'not available'
let column = 0
let row = 0
let fileName = currentFile
if (item.sourceMap && item.sourceMap.length) { if (item.location) {
let path = item.sourceMap[0].source_mapping.filename_relative const split = item.location.split(':')
let fileIndex = Object.keys(lastCompilationResult.sources).indexOf(path) const file = split[2]
if (fileIndex === -1) { location = {
path = await props.analysisModule.call('fileManager', 'getUrlFromPath', path) start: parseInt(split[0]),
fileIndex = Object.keys(lastCompilationResult.sources).indexOf(path.file) length: parseInt(split[1])
} }
if (fileIndex >= 0) { location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn(
location = { location,
start: item.sourceMap[0].source_mapping.start, parseInt(file),
length: item.sourceMap[0].source_mapping.length lastCompilationSource.sources,
} lastCompilationResult.sources
location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn( )
location, row = location.start.line
fileIndex, column = location.start.column
lastCompilationSource.sources, locationString = row + 1 + ':' + column + ':'
lastCompilationResult.sources fileName = Object.keys(lastCompilationResult.sources)[file]
) }
row = location.start.line if(fileName !== currentFile) {
column = location.start.column const {file, provider} = await props.analysisModule.call('fileManager', 'getPathFromUrl', fileName)
locationString = row + 1 + ':' + column + ':' if (file.startsWith('.deps') || (provider.type === 'localhost' && file.startsWith('localhost/node_modules'))) isLibrary = true
fileName = Object.keys(lastCompilationResult.sources)[fileIndex] }
} const msg = message(result.name, item.warning, item.more, fileName, locationString)
} const options = {
warningCount++ type: 'warning',
const msg = message(item.title, item.description, item.more, fileName, locationString) useSpan: true,
const options = { errFile: fileName,
type: 'warning', fileName,
useSpan: true, isLibrary,
errFile: fileName, errLine: row,
fileName, errCol: column,
errLine: row, item: item,
errCol: column, name: result.name,
item: { warning: item.description }, locationString,
name: item.title, more: item.more,
locationString, location: location
more: item.more, }
location: location warningErrors.push(options)
warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName })
}
}
// Slither Analysis
if (slitherEnabled) {
try {
const compilerState = await props.analysisModule.call('solidity', 'getCompilerState')
const { currentVersion, optimize, evmVersion } = compilerState
await props.analysisModule.call('terminal', 'log', { type: 'info', value: '[Slither Analysis]: Running...' })
_paq.push(['trackEvent', 'solidityStaticAnalyzer', 'analyzeWithSlither'])
const result = await props.analysisModule.call('slither', 'analyse', state.file, { currentVersion, optimize, evmVersion })
if (result.status) {
props.analysisModule.call('terminal', 'log', { type: 'info', value: `[Slither Analysis]: Analysis Completed!! ${result.count} warnings found.` })
const report = result.data
for (const item of report) {
let location: any = {}
let locationString = 'not available'
let column = 0
let row = 0
let fileName = currentFile
let isLibrary = false
if (item.sourceMap && item.sourceMap.length) {
let path = item.sourceMap[0].source_mapping.filename_relative
let fileIndex = Object.keys(lastCompilationResult.sources).indexOf(path)
if (fileIndex === -1) {
path = await props.analysisModule.call('fileManager', 'getUrlFromPath', path)
fileIndex = Object.keys(lastCompilationResult.sources).indexOf(path.file)
}
if (fileIndex >= 0) {
location = {
start: item.sourceMap[0].source_mapping.start,
length: item.sourceMap[0].source_mapping.length
} }
warningErrors.push(options) location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn(
warningMessage.push({ msg, options, hasWarning: true, warningModuleName: 'Slither Analysis' }) location,
fileIndex,
lastCompilationSource.sources,
lastCompilationResult.sources
)
row = location.start.line
column = location.start.column
locationString = row + 1 + ':' + column + ':'
fileName = Object.keys(lastCompilationResult.sources)[fileIndex]
} }
showWarnings(warningMessage, 'warningModuleName')
props.event.trigger('staticAnaysisWarning', [warningCount])
} }
}).catch(() => { if(fileName !== currentFile) {
props.analysisModule.call('terminal', 'log', { type: 'error', value: '[Slither Analysis]: Error occured! See remixd console for details.' }) const {file, provider} = await props.analysisModule.call('fileManager', 'getPathFromUrl', fileName)
showWarnings(warningMessage, 'warningModuleName') if (file.startsWith('.deps') || (provider.type === 'localhost' && file.startsWith('localhost/node_modules'))) isLibrary = true
}) }
}) const msg = message(item.title, item.description, item.more, fileName, locationString)
} else { const options = {
type: 'warning',
useSpan: true,
errFile: fileName,
fileName,
isLibrary,
errLine: row,
errCol: column,
item: { warning: item.description },
name: item.title,
locationString,
more: item.more,
location: location
}
warningErrors.push(options)
warningMessage.push({ msg, options, hasWarning: true, warningModuleName: 'Slither Analysis' })
}
showWarnings(warningMessage, 'warningModuleName')
}
} catch(error) {
props.analysisModule.call('terminal', 'log', { type: 'error', value: '[Slither Analysis]: Error occured! See remixd console for details.' })
showWarnings(warningMessage, 'warningModuleName') showWarnings(warningMessage, 'warningModuleName')
props.event.trigger('staticAnaysisWarning', [warningCount])
} }
}) } else showWarnings(warningMessage, 'warningModuleName')
} else { } else {
if (categoryIndex.length) { if (categoryIndex.length) {
warningContainer.current.innerText = 'No compiled AST available' warningContainer.current.innerText = 'No compiled AST available'
@ -346,6 +381,17 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
} }
} }
const handleShowLibsWarning = () => {
if (showLibsWarning) {
showLibsWarning = false
setShowLibsWarning(false)
} else {
showLibsWarning = true
setShowLibsWarning(true)
}
filterWarnings()
}
const categoryItem = (categoryId, item, i) => { const categoryItem = (categoryId, item, i) => {
return ( return (
<div className="form-check" key={i}> <div className="form-check" key={i}>
@ -409,6 +455,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
<RemixUiCheckbox <RemixUiCheckbox
id="checkAllEntries" id="checkAllEntries"
inputType="checkbox" inputType="checkbox"
title="Select all Remix analysis modules"
checked={Object.values(groupedModules).map((value: any) => { checked={Object.values(groupedModules).map((value: any) => {
return (value.map(x => { return (value.map(x => {
return x._index.toString() return x._index.toString()
@ -421,12 +468,13 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
<RemixUiCheckbox <RemixUiCheckbox
id="autorunstaticanalysis" id="autorunstaticanalysis"
inputType="checkbox" inputType="checkbox"
title="Run static analysis after the compilation"
onClick={handleAutoRun} onClick={handleAutoRun}
checked={autoRun} checked={autoRun}
label="Autorun" label="Autorun"
onChange={() => {}} onChange={() => {}}
/> />
<Button buttonText="Run" onClick={() => run(state.data, state.source, state.file)} disabled={(state.data === null || categoryIndex.length === 0) && !slitherEnabled }/> <Button buttonText="Run" onClick={async () => await run(state.data, state.source, state.file)} disabled={(state.data === null || categoryIndex.length === 0) && !slitherEnabled }/>
</div> </div>
{ showSlither && { showSlither &&
<div className="d-flex mt-2" id="enableSlitherAnalysis"> <div className="d-flex mt-2" id="enableSlitherAnalysis">
@ -469,14 +517,25 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
{state.file} {state.file}
</span> </span>
</div> </div>
<br/>
{Object.entries(warningState).length > 0 && {Object.entries(warningState).length > 0 &&
<div id='staticanalysisresult' > <div id='staticanalysisresult' >
<RemixUiCheckbox
id="showLibWarnings"
name="showLibWarnings"
categoryId="showLibWarnings"
title="when checked, the results are also displayed for external contract libraries"
inputType="checkbox"
checked={showLibsWarning}
label="Display all results"
onClick={handleShowLibsWarning}
onChange={() => {}}
/>
<br/>
<div className="mb-4"> <div className="mb-4">
{ {
(Object.entries(warningState).map((element, index) => ( (Object.entries(warningState).map((element, index) => (
<div key={index}> <div key={index}>
<span className="text-dark h6">{element[0]}</span> {element[1]['length'] > 0 ? <span className="text-dark h6">{element[0]}</span> : null}
{element[1]['map']((x, i) => ( // eslint-disable-line dot-notation {element[1]['map']((x, i) => ( // eslint-disable-line dot-notation
x.hasWarning ? ( // eslint-disable-next-line dot-notation x.hasWarning ? ( // eslint-disable-next-line dot-notation
<div data-id={`staticAnalysisModule${x.warningModuleName}${i}`} id={`staticAnalysisModule${x.warningModuleName}${i}`} key={i}> <div data-id={`staticAnalysisModule${x.warningModuleName}${i}`} id={`staticAnalysisModule${x.warningModuleName}${i}`} key={i}>

Loading…
Cancel
Save