From 1de29961c4b8e3ee086351f5baf195b5c1e7d3e0 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 20 Jun 2023 16:33:06 +0100 Subject: [PATCH 01/68] reset warnings and errors correctly --- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 6 ++++++ 1 file changed, 6 insertions(+) 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 603b87ad08..1f35d4a677 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 @@ -107,11 +107,17 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } useEffect(() => { + setHints([]) + setSlitherWarnings([]) + setSsaWarnings([]) compilation(props.analysisModule, dispatch) }, [props]) useEffect(() => { setWarningState({}) + setHints([]) + setSlitherWarnings([]) + setSsaWarnings([]) 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, setStartAnalysis) } From 171617d1e3fa8fd6f6261885a5715508d17130ec Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 20 Jun 2023 22:22:57 +0100 Subject: [PATCH 02/68] fix badge logic. make tab switching stateful --- .../src/lib/components/BasicTitle.tsx | 17 +++++---- .../src/lib/remix-ui-static-analyser.tsx | 38 +++++++++++-------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx b/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx index 51a539418d..8f3c2307df 100644 --- a/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx +++ b/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx @@ -4,6 +4,7 @@ import { ErrorRendererOptions } from '../../staticanalyser' type BasicTitleProps = { warningStateEntries: any hideWarnings?: boolean + showLibsWarnings?: boolean } type warningResultOption = { @@ -32,13 +33,15 @@ export function calculateWarningStateEntries(entries: [string, any][]) { export function BasicTitle(props: BasicTitleProps) { return ( - Remix{props.warningStateEntries.length > 0 ? !props.hideWarnings ? 0 ? 'badge-warning' : 'badge-danger'} rounded-circle ml-1 text-center`}>{calculateWarningStateEntries(props.warningStateEntries).length}: ( - - { - calculateWarningStateEntries(props.warningStateEntries).errors.length - } - - ) : null} + Remix{props.warningStateEntries.length > 0 ? !props.hideWarnings ? props.showLibsWarnings ? 0 ? 'badge-warning' : 'badge-danger'} rounded-circle ml-1 text-center`}> + { + calculateWarningStateEntries(props.warningStateEntries).length}: ( + + { + calculateWarningStateEntries(props.warningStateEntries).errors.length + } + + ) : null : null} ) } 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 1f35d4a677..361da8684a 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 @@ -81,6 +81,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const [hints, setHints] = useState([]) const [slitherWarnings, setSlitherWarnings] = useState([]) const [ssaWarnings, setSsaWarnings] = useState([]) + const [tabKey, setTabKey] = useState('basic') const warningContainer = useRef(null) const allWarnings = useRef({}) @@ -107,6 +108,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } useEffect(() => { + setWarningState({}) setHints([]) setSlitherWarnings([]) setSsaWarnings([]) @@ -143,7 +145,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { useEffect(() => { props.analysisModule.on('filePanel', 'setWorkspace', (currentWorkspace) => { // Reset warning state - setWarningState([]) + setWarningState({}) // Reset badge props.event.trigger('staticAnaysisWarning', []) // Reset state @@ -165,7 +167,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { // Hide 'Enable Slither Analysis' checkbox if (plugin.name === 'remixd') { // Reset warning state - setWarningState([]) + setWarningState({}) setHints([]) setSlitherWarnings([]) setSlitherEnabled(false) @@ -218,8 +220,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } } } - props.event.trigger('staticAnaysisWarning', [newWarningCount]) - setWarningState(newWarningState) + if (newWarningCount > 0) { + props.event.trigger('staticAnaysisWarning', [newWarningCount]) + setWarningState(newWarningState) + } } useEffect(() => { @@ -511,6 +515,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ), child: ( @@ -520,8 +525,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
{Object.entries(warningState).map((element, index) => (
- { !hideWarnings && element[1]['length'] > 0 ? {element[0]} : null} - {!hideWarnings ? element[1]["map"]( + { hideWarnings === false ? {element[0]} : null} + { hideWarnings === false ? element[1]["map"]( (x,i) => // eslint-disable-line dot-notation x.hasWarning ? ( // eslint-disable-next-line dot-notation @@ -753,8 +758,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { />
setTabKey(newKey)} > { checkBasicStatus() ? { {tabKeys[1].child} : null } - {solhintEnabled ? - {tabKeys[0].child} - : null} + { + solhintEnabled ? + {tabKeys[0].child} + : null + } { showSlither && slitherEnabled ? Date: Tue, 20 Jun 2023 22:26:15 +0100 Subject: [PATCH 03/68] work on badge tooltip --- .../vertical-icons-panel/src/lib/components/Badge.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/vertical-icons-panel/src/lib/components/Badge.tsx b/libs/remix-ui/vertical-icons-panel/src/lib/components/Badge.tsx index 1a7d19052d..18161e8da5 100644 --- a/libs/remix-ui/vertical-icons-panel/src/lib/components/Badge.tsx +++ b/libs/remix-ui/vertical-icons-panel/src/lib/components/Badge.tsx @@ -49,7 +49,13 @@ function Badge ({ badgeStatus }: BadgeProps) { return ( <> { - badgeStatus && checkStatusKeyValue(badgeStatus.key, badgeStatus.type) ? ( + badgeStatus && checkStatusKeyValue(badgeStatus.key, badgeStatus.type) ? ( + :   : badgeStatus.text } - ) : null + ) : null } ) From 8936c4e8342047ab274c80e8835c073a5bf6f478 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 21 Jun 2023 00:55:12 +0100 Subject: [PATCH 04/68] abstract basic tab markup into its own component --- .../src/lib/remix-ui-static-analyser.tsx | 71 +++++-------------- 1 file changed, 16 insertions(+), 55 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 361da8684a..f68dc2ca01 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 @@ -16,6 +16,7 @@ import Tabs from 'react-bootstrap/Tabs' import { AnalysisTab, SolHintReport } from '../staticanalyser' import { run } from './actions/staticAnalysisActions' import { BasicTitle, calculateWarningStateEntries } from './components/BasicTitle' +import { BasicTabBody } from './components/BasicTabBody' declare global { interface Window { @@ -74,7 +75,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { 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 [showLibsWarning, setShowLibsWarning] = useState(false) // eslint-disable-line prefer-const const [categoryIndex, setCategoryIndex] = useState(groupedModuleIndex(groupedModules)) const [warningState, setWarningState] = useState({}) const [hideWarnings, setHideWarnings] = useState(false) @@ -109,6 +110,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { useEffect(() => { setWarningState({}) + allWarnings.current = {} setHints([]) setSlitherWarnings([]) setSsaWarnings([]) @@ -116,6 +118,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { }, [props]) useEffect(() => { + allWarnings.current = {} setWarningState({}) setHints([]) setSlitherWarnings([]) @@ -145,6 +148,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { useEffect(() => { props.analysisModule.on('filePanel', 'setWorkspace', (currentWorkspace) => { // Reset warning state + allWarnings.current = {} setWarningState({}) // Reset badge props.event.trigger('staticAnaysisWarning', []) @@ -201,6 +205,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } const filterWarnings = () => { + console.log({ allWarnings }) let newWarningState = {} let newWarningCount = 0 if (showLibsWarning) { @@ -220,7 +225,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } } } - if (newWarningCount > 0) { + if (newWarningCount > 0 && state.data && state.source !== null) { props.event.trigger('staticAnaysisWarning', [newWarningCount]) setWarningState(newWarningState) } @@ -318,13 +323,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const handleShowLibsWarning = () => { if (showLibsWarning) { - showLibsWarning = false setShowLibsWarning(false) } else { - showLibsWarning = true + filterWarnings() setShowLibsWarning(true) } - filterWarnings() } const categoryItem = (categoryId, item, i) => { @@ -519,56 +522,14 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { /> ), child: ( - <> - {Object.entries(warningState).length > 0 ? ( -
-
- {Object.entries(warningState).map((element, index) => ( -
- { hideWarnings === false ? {element[0]} : null} - { hideWarnings === false ? element[1]["map"]( - (x,i) => // eslint-disable-line dot-notation - x.hasWarning - ? ( // eslint-disable-next-line dot-notation -
- -
- ) : null - ) : element[1]["map"]( - (x,i) => // eslint-disable-line dot-notation - !x.hasWarning - ? ( // eslint-disable-next-line dot-notation -
- -
- ) : null)} - {} -
- ))} -
-
- ) : state.data && state.file.length > 0 && state.source && startAnalysis && Object.entries(warningState).length > 0 ? Loading... : Nothing to report} - + ), }, { From 5f9e20486f4cf7963f5eb6be51c7e1796715bcdd Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 21 Jun 2023 00:55:30 +0100 Subject: [PATCH 05/68] basictabcomponent --- .../src/lib/components/BasicTabBody.tsx | 66 +++++++++++++++++++ .../src/lib/components/BasicTitle.tsx | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx diff --git a/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx b/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx new file mode 100644 index 0000000000..4c0ca1aeb8 --- /dev/null +++ b/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx @@ -0,0 +1,66 @@ +import React from 'react' +import ErrorRenderer from "../ErrorRenderer" + +type BasicTabBodyProps = { + state: any + hideWarnings: boolean + showLibsWarning: boolean + warningState: any + startAnalysis: boolean + analysisModule: any +} +export function BasicTabBody({ state, hideWarnings, showLibsWarning, warningState, startAnalysis, analysisModule}: BasicTabBodyProps) { + + return ( + <> + {Object.entries(warningState).length > 0 ? ( +
+
+ {Object.entries(warningState).map((element, index) => ( +
+ { hideWarnings === false ? {element[0]} : null} + { hideWarnings === false ? element[1]["map"]( + (x,i) => // eslint-disable-line dot-notation + x.hasWarning + ? ( // eslint-disable-next-line dot-notation +
+ +
+ ) : null + ) : element[1]["map"]( + (x,i) => // eslint-disable-line dot-notation + showLibsWarning && x.isLibrary + ? ( // eslint-disable-next-line dot-notation +
+ +
+ ) : null)} + {} +
+ ))} +
+
+ ) : state.data && state.file.length > 0 && state.source && startAnalysis && Object.entries(warningState).length > 0 ? Loading... : Nothing to report} + + ) +} diff --git a/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx b/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx index 8f3c2307df..5605c1254d 100644 --- a/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx +++ b/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx @@ -38,7 +38,7 @@ export function BasicTitle(props: BasicTitleProps) { calculateWarningStateEntries(props.warningStateEntries).length}: ( { - calculateWarningStateEntries(props.warningStateEntries).errors.length + calculateWarningStateEntries(props.warningStateEntries).length } ) : null : null} From 64bb7aa0daf3175fa3c94ab7fa0bcc7c580bcd3d Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 21 Jun 2023 10:42:19 +0100 Subject: [PATCH 06/68] fix badge for tab title --- .../static-analyser/src/lib/components/BasicTitle.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx b/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx index 5605c1254d..0a66512208 100644 --- a/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx +++ b/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useEffect } from 'react' import { ErrorRendererOptions } from '../../staticanalyser' type BasicTitleProps = { @@ -31,14 +31,18 @@ export function calculateWarningStateEntries(entries: [string, any][]) { } export function BasicTitle(props: BasicTitleProps) { + const[warningCount, setWarningCount] = React.useState(props.warningStateEntries.length) + useEffect(() => { + + }, [props.warningStateEntries.length]) return ( - Remix{props.warningStateEntries.length > 0 ? !props.hideWarnings ? props.showLibsWarnings ? 0 ? 'badge-warning' : 'badge-danger'} rounded-circle ml-1 text-center`}> + Remix{props.warningStateEntries.length > 0 ? !props.hideWarnings ? !props.showLibsWarnings ? 0 ? 'badge-warning' : 'badge-danger'} rounded-circle ml-1 text-center`}> { calculateWarningStateEntries(props.warningStateEntries).length}: ( { - calculateWarningStateEntries(props.warningStateEntries).length + warningCount } ) : null : null} From 739e0ff5e5e8f4b0820ccb4a796a6d88c74bfab4 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 21 Jun 2023 10:42:37 +0100 Subject: [PATCH 07/68] refactor Remix tab body --- .../src/lib/components/BasicTabBody.tsx | 61 ++++++++++++------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx b/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx index 4c0ca1aeb8..e06aa67bda 100644 --- a/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx +++ b/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx @@ -16,10 +16,10 @@ export function BasicTabBody({ state, hideWarnings, showLibsWarning, warningStat {Object.entries(warningState).length > 0 ? (
- {Object.entries(warningState).map((element, index) => ( + {Object.entries(warningState).map((warning, index) => (
- { hideWarnings === false ? {element[0]} : null} - { hideWarnings === false ? element[1]["map"]( + { hideWarnings === false ? {warning[0]} : null} + { hideWarnings === false ? warning[1]["map"]( (x,i) => // eslint-disable-line dot-notation x.hasWarning ? ( // eslint-disable-next-line dot-notation @@ -36,26 +36,43 @@ export function BasicTabBody({ state, hideWarnings, showLibsWarning, warningStat editor={analysisModule} />
- ) : null - ) : element[1]["map"]( - (x,i) => // eslint-disable-line dot-notation - showLibsWarning && x.isLibrary - ? ( // eslint-disable-next-line dot-notation + ) : null) : null} + { + hideWarnings === false ? warning[1]["map"]((x,i) =>( + showLibsWarning === false ? ( + x.isLibrary ? (
- -
- ) : null)} - {} + data-id={`staticAnalysisModule${x.warningModuleName}${i}`} + id={`staticAnalysisModule${x.warningModuleName}${i}`} + key={i} + > + +
+ ) : null): null)) : null + } + { + hideWarnings === false ? warning[1]["map"]((x,i) =>( +
3 + +
+ )) : null + }
))}
From 44d93c18112575ab81d43df745bf4057a0211a35 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 21 Jun 2023 10:56:08 +0100 Subject: [PATCH 08/68] dev log cleanup --- .../static-analyser/src/lib/components/BasicTabBody.tsx | 2 +- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx b/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx index e06aa67bda..c9625c0b92 100644 --- a/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx +++ b/libs/remix-ui/static-analyser/src/lib/components/BasicTabBody.tsx @@ -62,7 +62,7 @@ export function BasicTabBody({ state, hideWarnings, showLibsWarning, warningStat data-id={`staticAnalysisModule${x.warningModuleName}${i}`} id={`staticAnalysisModule${x.warningModuleName}${i}`} key={i} - >3 + > { } const filterWarnings = () => { - console.log({ allWarnings }) let newWarningState = {} let newWarningCount = 0 if (showLibsWarning) { From b97fa0fedf55b2817b1473639652c29f8d05ad42 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 21 Jun 2023 11:07:07 +0100 Subject: [PATCH 09/68] tooltip for button. change Linter to Solhint checkbox --- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 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 3e6057dc0e..80babd6642 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 @@ -647,10 +647,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { {}} tooltipPlacement={'bottom-start'} optionalClassName="mr-3" @@ -671,6 +671,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { {state.data && state.file.length > 0 && state.source ?