conditionally render analysis result section fix

pull/5370/head
Joseph Izang 1 year ago
parent c467a0625c
commit ccc5bdd984
  1. 51
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -365,8 +365,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
onChange={() => {}} onChange={() => {}}
/> />
</div> </div>
) );
} };
const categorySection = (category, categoryId, i) => { const categorySection = (category, categoryId, i) => {
return ( return (
@ -416,8 +416,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
</TreeView> </TreeView>
</div> </div>
</div> </div>
) );
} };
useEffect(() => { useEffect(() => {
if (!hideWarnings && !showLibsWarning) { if (!hideWarnings && !showLibsWarning) {
@ -437,35 +437,35 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
slitherTotal + ssaTotal + hintsTotal === 0 slitherTotal + ssaTotal + hintsTotal === 0
? -1 ? -1
: slitherTotal + ssaTotal + hintsTotal, : slitherTotal + ssaTotal + hintsTotal,
]) ]);
} }
if (!hideWarnings && showLibsWarning) { if (!hideWarnings && showLibsWarning) {
props.event.trigger("staticAnaysisWarning", [ props.event.trigger("staticAnaysisWarning", [
slitherWarnings.length + ssaWarnings.length + hints.length === 0 slitherWarnings.length + ssaWarnings.length + hints.length === 0
? -1 ? -1
: slitherWarnings.length + ssaWarnings.length + hints.length, : slitherWarnings.length + ssaWarnings.length + hints.length,
]) ]);
} }
if (hideWarnings) { if (hideWarnings) {
const slitherTotal = const slitherTotal =
slitherWarnings && state.data && state.source !== null slitherWarnings && state.data && state.source !== null
? slitherWarnings.filter((x) => x.options.type === "error").length ? slitherWarnings.filter((x) => x.options.type === "error").length
: 0 : 0;
const ssaTotal = const ssaTotal =
ssaWarnings && state.data && state.source !== null ssaWarnings && state.data && state.source !== null
? ssaWarnings.filter((x) => x.options.type === "error").length ? ssaWarnings.filter((x) => x.options.type === "error").length
: 0 : 0;
const hintsTotal = const hintsTotal =
hints && state.data && state.source !== null hints && state.data && state.source !== null
? hints.filter((x) => x.type === "error").length ? hints.filter((x) => x.type === "error").length
: 0 : 0;
props.event.trigger("staticAnaysisWarning", [ props.event.trigger("staticAnaysisWarning", [
slitherTotal + ssaTotal + hintsTotal === 0 slitherTotal + ssaTotal + hintsTotal === 0
? -1 ? -1
: slitherTotal + ssaTotal + hintsTotal, : slitherTotal + ssaTotal + hintsTotal,
]) ]);
} }
}, [hideWarnings, showLibsWarning]) }, [hideWarnings, showLibsWarning]);
useEffect(() => { useEffect(() => {
const slitherTotal = const slitherTotal =
@ -476,21 +476,21 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
state.source !== null state.source !== null
? slitherWarnings.filter((x) => !x.options.isLibrary && x.hasWarning) ? slitherWarnings.filter((x) => !x.options.isLibrary && x.hasWarning)
.length .length
: 0 : 0;
const ssaTotal = const ssaTotal =
basicEnabled && ssaWarnings && state.data && state.source !== null basicEnabled && ssaWarnings && state.data && state.source !== null
? ssaWarnings.filter((x) => !x.options.isLibrary && x.hasWarning).length ? ssaWarnings.filter((x) => !x.options.isLibrary && x.hasWarning).length
: 0 : 0;
const hintsTotal = const hintsTotal =
solhintEnabled && hints && state.data && state.source !== null solhintEnabled && hints && state.data && state.source !== null
? hints.length ? hints.length
: 0 : 0;
props.event.trigger("staticAnaysisWarning", [ props.event.trigger("staticAnaysisWarning", [
slitherTotal + ssaTotal + hintsTotal === 0 slitherTotal + ssaTotal + hintsTotal === 0
? -1 ? -1
: slitherTotal + ssaTotal + hintsTotal, : slitherTotal + ssaTotal + hintsTotal,
]) ]);
}, [hints.length, slitherWarnings.length, ssaWarnings.length]) }, [hints.length, slitherWarnings.length, ssaWarnings.length]);
useEffect(() => { useEffect(() => {
const slitherTotal = const slitherTotal =
@ -501,21 +501,21 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
state.source !== null state.source !== null
? slitherWarnings.filter((x) => !x.options.isLibrary && x.hasWarning) ? slitherWarnings.filter((x) => !x.options.isLibrary && x.hasWarning)
.length .length
: 0 : 0;
const ssaTotal = const ssaTotal =
ssaWarnings && basicEnabled && state.data && state.source !== null ssaWarnings && basicEnabled && state.data && state.source !== null
? ssaWarnings.filter((x) => !x.options.isLibrary && x.hasWarning).length ? ssaWarnings.filter((x) => !x.options.isLibrary && x.hasWarning).length
: 0 : 0;
const hintsTotal = const hintsTotal =
hints && solhintEnabled && state.data && state.source !== null hints && solhintEnabled && state.data && state.source !== null
? hints.length ? hints.length
: 0 : 0;
props.event.trigger("staticAnaysisWarning", [ props.event.trigger("staticAnaysisWarning", [
slitherTotal + ssaTotal + hintsTotal === 0 slitherTotal + ssaTotal + hintsTotal === 0
? -1 ? -1
: slitherTotal + ssaTotal + hintsTotal, : slitherTotal + ssaTotal + hintsTotal,
]); ]);
}, [solhintEnabled, basicEnabled, slitherEnabled, showSlither]) }, [solhintEnabled, basicEnabled, slitherEnabled, showSlither]);
const handleSlitherEnabled = async () => { const handleSlitherEnabled = async () => {
const checkRemixd = await props.analysisModule.call( const checkRemixd = await props.analysisModule.call(
@ -892,7 +892,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
</> </>
), ),
}, },
] ];
const checkBasicStatus = () => { const checkBasicStatus = () => {
return Object.values(groupedModules) return Object.values(groupedModules)
@ -903,7 +903,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}) })
.flat() .flat()
.every((el) => categoryIndex.includes(el)); .every((el) => categoryIndex.includes(el));
} };
return ( return (
<div className="analysis_3ECCBV px-3 pb-1"> <div className="analysis_3ECCBV px-3 pb-1">
<div className="my-2 d-flex flex-column align-items-left"> <div className="my-2 d-flex flex-column align-items-left">
@ -919,7 +919,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
.map((value: any) => { .map((value: any) => {
return value.map((x) => { return value.map((x) => {
return x._index.toString(); return x._index.toString();
}) });
}) })
.flat() .flat()
.every((el) => categoryIndex.includes(el)) .every((el) => categoryIndex.includes(el))
@ -1043,10 +1043,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
} }
/> />
)} )}
{state && {ssaWarnings.length > 0 && hints.length > 0 ? (
state.data !== null &&
state.source !== null &&
state.file.length > 0 ? (
<div className="d-flex border-top flex-column"> <div className="d-flex border-top flex-column">
{slitherWarnings.length > 0 || {slitherWarnings.length > 0 ||
hints.length > 0 || hints.length > 0 ||

Loading…
Cancel
Save