From b083b7983e4e9fa672aa3fcd92904137c3be82cd Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Thu, 22 Jun 2023 00:44:57 +0100 Subject: [PATCH] filter warnings --- .../src/lib/remix-ui-static-analyser.tsx | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) 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 e79c331c93..4c63b5710d 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 @@ -9,7 +9,7 @@ import * as semver from 'semver' import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line import { RemixUiCheckbox } from '@remix-ui/checkbox' // eslint-disable-line import ErrorRenderer from './ErrorRenderer' // eslint-disable-line -import { compilation } from './actions/staticAnalysisActions' +import { compilation, runSlitherAnalysis } from './actions/staticAnalysisActions' import { initialState, analysisReducer } from './reducers/staticAnalysisReducer' import { CodeAnalysis } from '@remix-project/remix-analyzer' import Tab from 'react-bootstrap/Tab' @@ -197,6 +197,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { return () => { } }, [props]) + const hintErrors = hints.filter(hint => hint.type === 'error') + const noLibSlitherWarnings = slitherWarnings.filter(w => !w.options.isLibrary) + const slitherErrors = noLibSlitherWarnings.filter(slitherError => slitherError.options.type === 'error') + const remixAnalysisNoLibs = ssaWarnings.filter(ssa => ssa.options.isLibrary === false) + const message = (name: string, warning: any, more?: string, fileName?: string, locationString?: string) : string => { return (` @@ -243,6 +248,17 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } },[hints.length, state]) + useEffect(() => { + if(ssaWarnings.length > 0) { + props.event.trigger('staticAnaysisWarning', [ssaWarnings.length]) + } + if(remixAnalysisNoLibs.length > 0) { + props.event.trigger('staticAnaysisWarning', [remixAnalysisNoLibs.length]) + } + }, [ssaWarnings.length]) + + + const showWarnings = (warningMessage, groupByKey) => { const resultArray = [] warningMessage.map(x => { @@ -329,9 +345,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const handleShowLibsWarning = () => { if (showLibsWarning) { + props.event.trigger('staticAnaysisWarning', [remixAnalysisNoLibs.length]) setShowLibsWarning(false) } else { - filterWarnings() + // filterWarnings() + props.event.trigger('staticAnaysisWarning', [ssaWarnings.length]) setShowLibsWarning(true) } } @@ -396,9 +414,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { setHideWarnings(!hideWarnings) } - const hintErrors = hints.filter(hint => hint.type === 'error') - const noLibSlitherWarnings = slitherWarnings.filter(w => !w.options.isLibrary) - const slitherErrors = noLibSlitherWarnings.filter(slitherError => slitherError.options.type === 'error') + console.log({ ssaWarnings, remixAnalysisNoLibs, slitherWarnings, hints }) const tabKeys = [ { @@ -522,19 +538,23 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { tabKey: "basic", title: ( ), child: ( ), }, @@ -680,8 +700,13 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { buttonText={`Analyse ${state.file}`} title={`${runButtonTitle}`} classList="btn btn-sm btn-primary btn-block" - onClick={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, setStartAnalysis)} + onClick={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, setStartAnalysis) + await runSlitherAnalysis(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) + } + } disabled={(state.data === null || !isSupportedVersion) || (!solhintEnabled && !basicEnabled) } /> :