From eff89b5cc318aaf46ade2ef64e097940fd3e1771 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 14 Jun 2023 10:40:11 +0100 Subject: [PATCH] finish final changes requested by @ryestew --- .../src/lib/actions/staticAnalysisActions.ts | 5 ++-- .../src/lib/remix-ui-static-analyser.tsx | 26 +++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts b/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts index 30989e5b39..aa9ce0e3bb 100644 --- a/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts +++ b/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts @@ -44,8 +44,8 @@ export const compilation = (analysisModule: AnalysisTab, */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export async function run (lastCompilationResult, lastCompilationSource, currentFile: string, state: RemixUiStaticAnalyserState, props: RemixUiStaticAnalyserProps, isSupportedVersion, showSlither, categoryIndex: number[], groupedModules, runner, _paq, message, showWarnings, allWarnings: React.RefObject, warningContainer: React.RefObject, calculateWarningStateEntries: (e:[string, any][]) => {length: number, errors: any[] }, warningState, setHints: React.Dispatch>, hints: SolHintReport[], setSlitherWarnings: React.Dispatch>, setSsaWarnings: React.Dispatch>, -slitherEnabled: boolean) { - +slitherEnabled: boolean, setStartAnalysis: React.Dispatch>) { + setStartAnalysis(true) if (!isSupportedVersion) return if (state.data !== null) { if (lastCompilationResult && (categoryIndex.length > 0 || showSlither)) { @@ -199,6 +199,7 @@ slitherEnabled: boolean) { showWarnings(warningMessage, 'warningModuleName') } } else showWarnings(warningMessage, 'warningModuleName') + setStartAnalysis(false) } else { if (categoryIndex.length) { warningContainer.current.innerText = 'No compiled AST available' diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index d41ae55d22..3ef8d5ed7b 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -72,6 +72,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const [solhintEnabled, setSolhintEnabled] = useState(true) // assuming that solhint is always enabled const [showSlither, setShowSlither] = useState(false) const [slitherEnabled, setSlitherEnabled] = useState(false) + const [startAnalysis, setStartAnalysis] = useState(false) const [isSupportedVersion, setIsSupportedVersion] = useState(false) let [showLibsWarning, setShowLibsWarning] = useState(false) // eslint-disable-line prefer-const const [categoryIndex, setCategoryIndex] = useState(groupedModuleIndex(groupedModules)) @@ -112,7 +113,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { useEffect(() => { setWarningState({}) const runAnalysis = async () => { - await run(state.data, state.source, state.file, state, props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, message, showWarnings, allWarnings, warningContainer,calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled) + await run(state.data, state.source, state.file, state, props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, message, showWarnings, allWarnings, warningContainer,calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis) } props.event.trigger('staticAnaysisWarning', []) // if (basicEnabled) { @@ -465,7 +466,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { - ) : No Results.} + ) : state.data && state.file.length > 0 && state.source && startAnalysis && hints.length > 0 ? Loading... : Nothing to report} ), title: ( @@ -526,7 +527,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ))} - ) : No Results.} + ) : state.data && state.file.length > 0 && state.source && startAnalysis && Object.entries(warningState).length > 0 ? Loading... : Nothing to report} ), }, @@ -602,7 +603,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { - ) : No Result} + ) : state.data && state.file.length > 0 && state.source && startAnalysis && slitherWarnings.length > 0 ? Loading... : Nothing to report} ), }, @@ -642,7 +643,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { { label="Slither" onChange={() => {}} optionalClassName="mr-3" - title={slitherEnabled ? "Run Slither static analysis." : "To run Slither analysis, Remix IDE must be connected to your local filesystem with Remixd."} + title={slitherEnabled ? "Slither runs Slither static analysis." : "To run Slither analysis, Remix IDE must be connected to your local filesystem with Remixd."} /> {state.data && state.file.length > 0 && state.source ?