refactor run button logic

pull/3838/head
Joseph Izang 1 year ago
parent 8e1025c2d1
commit 86d69d9afe
  1. 20
      libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts

@ -31,16 +31,14 @@ export const runLinting = async (solhintEnabled, setHints, hints: SolHintReport[
if (!isSupportedVersion) return if (!isSupportedVersion) return
if (solhintEnabled === false) return if (solhintEnabled === false) return
if (state.data !== null) { if (state.data !== null) {
if (state.data && solhintEnabled) { if (solhintEnabled) {
props.analysisModule.hints = [] props.analysisModule.hints = []
setHints([]) setHints([])
const hintsResult = await props.analysisModule.call('solhint', 'lint', state.file) const hintsResult = await props.analysisModule.call('solhint', 'lint', state.file)
props.analysisModule.hints = solhintEnabled === false ? 0 : hintsResult props.analysisModule.hints = solhintEnabled === false ? 0 : hintsResult
setHints(hintsResult) return hintsResult
props.analysisModule.emit('statusChanged', { key: hints.length+warningResult.length, }
title: `${hints.length+warningResult.length} warning${hints.length+warningResult.length === 1 ? '' : 's'}`, type: 'warning'}) }
}
}
} }
/** /**
@ -73,6 +71,7 @@ slitherEnabled: boolean, setStartAnalysis: React.Dispatch<React.SetStateAction<b
if (!isSupportedVersion) return if (!isSupportedVersion) return
if (state.data !== null) { if (state.data !== null) {
if (lastCompilationResult && (categoryIndex.length > 0 || showSlither)) { if (lastCompilationResult && (categoryIndex.length > 0 || showSlither)) {
_paq.push(['trackEvent', 'solidityStaticAnalyzer', 'analyze', 'remixAnalyzer'])
const warningMessage = [] const warningMessage = []
const warningErrors = [] const warningErrors = []
@ -84,12 +83,11 @@ slitherEnabled: boolean, setStartAnalysis: React.Dispatch<React.SetStateAction<b
// props.analysisModule.emit('statusChanged', { key: hints.length+warningResult.length, // props.analysisModule.emit('statusChanged', { key: hints.length+warningResult.length,
// title: `${hints.length+warningResult.length} warning${hints.length+warningResult.length === 1 ? '' : 's'}`, type: 'warning'}) // title: `${hints.length+warningResult.length} warning${hints.length+warningResult.length === 1 ? '' : 's'}`, type: 'warning'})
runLinting(solhintEnabled, setHints, hints, warningResult, isSupportedVersion, state, props, setStartAnalysis) const lintResult = runLinting(solhintEnabled, setHints, hints, warningResult, isSupportedVersion, state, props, setStartAnalysis)
//---------------------------- RunLinting End ---------------------------- //---------------------------- RunLinting End ----------------------------
// Remix Analysis // Remix Analysis
_paq.push(['trackEvent', 'solidityStaticAnalyzer', 'analyze', 'remixAnalyzer'])
const results = runner.run(lastCompilationResult, categoryIndex) const results = runner.run(lastCompilationResult, categoryIndex)
for (const result of results) { for (const result of results) {
let moduleName let moduleName
@ -148,6 +146,8 @@ slitherEnabled: boolean, setStartAnalysis: React.Dispatch<React.SetStateAction<b
} }
warningErrors.push(options) warningErrors.push(options)
warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName }) warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName })
const newHints = await lintResult
setHints(newHints)
setSsaWarnings(warningMessage) setSsaWarnings(warningMessage)
} }
} }

Loading…
Cancel
Save