fix success badge issue

pull/3838/head
Joseph Izang 1 year ago
parent 1bc19a50f8
commit 6e1b12b5b0
  1. 23
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -116,6 +116,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
props.event.trigger('staticAnalysisWarning', [-1]) props.event.trigger('staticAnalysisWarning', [-1])
}, []) }, [])
useEffect(() => {
props.event.trigger('staticAnalysisWarning', [-1])
}, [state])
useEffect(() => { useEffect(() => {
const checkRemixdActive = async () => { const checkRemixdActive = async () => {
const remixdActive = await props.analysisModule.call('manager', 'isActive', 'remixd') const remixdActive = await props.analysisModule.call('manager', 'isActive', 'remixd')
@ -341,20 +345,21 @@ useEffect(() => {
const slitherTotal = (slitherWarnings && state.data && state.source !== null ? slitherWarnings.filter(x => !x.options.isLibrary && x.hasWarning).length : 0) const slitherTotal = (slitherWarnings && state.data && state.source !== null ? slitherWarnings.filter(x => !x.options.isLibrary && x.hasWarning).length : 0)
const ssaTotal = ssaWarnings && state.data && state.source !== null ? ssaWarnings.filter(x => !x.options.isLibrary && x.hasWarning).length : 0 const ssaTotal = ssaWarnings && state.data && state.source !== null ? ssaWarnings.filter(x => !x.options.isLibrary && x.hasWarning).length : 0
const hintsTotal = hints && state.data && state.source !== null ? hints.length : 0 const hintsTotal = hints && state.data && state.source !== null ? hints.length : 0
props.event.trigger('staticAnaysisWarning', [slitherTotal + ssaTotal + hintsTotal]) props.event.trigger('staticAnaysisWarning', [(slitherTotal + ssaTotal + hintsTotal) === 0 ? -1 : (slitherTotal + ssaTotal + hintsTotal)])
} }
if(!hideWarnings && showLibsWarning) { if(!hideWarnings && showLibsWarning) {
props.event.trigger('staticAnaysisWarning', [ props.event.trigger('staticAnaysisWarning', [
slitherWarnings.length (slitherWarnings.length
+ ssaWarnings.length + ssaWarnings.length
+ hints.length + hints.length) === 0 ? -1 : (slitherWarnings.length
]) + ssaWarnings.length
+ hints.length)])
} }
if(hideWarnings) { if(hideWarnings) {
const slitherTotal = (slitherWarnings && state.data && state.source !== null ? slitherWarnings.filter(x => x.options.type === 'error').length : 0) const slitherTotal = (slitherWarnings && state.data && state.source !== null ? slitherWarnings.filter(x => x.options.type === 'error').length : 0)
const ssaTotal = ssaWarnings && state.data && state.source !== null ? ssaWarnings.filter(x => x.options.type === 'error').length : 0 const ssaTotal = ssaWarnings && state.data && state.source !== null ? ssaWarnings.filter(x => x.options.type === 'error').length : 0
const hintsTotal = hints && state.data && state.source !== null ? hints.filter(x => x.type === 'error').length : 0 const hintsTotal = hints && state.data && state.source !== null ? hints.filter(x => x.type === 'error').length : 0
props.event.trigger('staticAnaysisWarning', [slitherTotal + ssaTotal + hintsTotal]) props.event.trigger('staticAnaysisWarning', [(slitherTotal + ssaTotal + hintsTotal) === 0 ? -1 : (slitherTotal + ssaTotal + hintsTotal)])
} }
}, [hideWarnings, showLibsWarning]) }, [hideWarnings, showLibsWarning])
@ -366,7 +371,7 @@ useEffect(() => {
? ssaWarnings.filter((x) => !x.options.isLibrary && x.hasWarning).length ? ssaWarnings.filter((x) => !x.options.isLibrary && x.hasWarning).length
: 0 : 0
const hintsTotal = solhintEnabled && hints && state.data && state.source !== null ? hints.length : 0 const hintsTotal = solhintEnabled && hints && state.data && state.source !== null ? hints.length : 0
props.event.trigger('staticAnaysisWarning', [slitherTotal + ssaTotal + hintsTotal]) props.event.trigger('staticAnaysisWarning', [(slitherTotal + ssaTotal + hintsTotal) === 0 ? -1 : (slitherTotal + ssaTotal + hintsTotal)])
}, [hints.length, slitherWarnings.length, ssaWarnings.length]) }, [hints.length, slitherWarnings.length, ssaWarnings.length])
useEffect(() => { useEffect(() => {
@ -377,7 +382,7 @@ useEffect(() => {
? ssaWarnings.filter((x) => !x.options.isLibrary && x.hasWarning).length ? ssaWarnings.filter((x) => !x.options.isLibrary && x.hasWarning).length
: 0 : 0
const hintsTotal = hints && solhintEnabled && state.data && state.source !== null ? hints.length : 0 const hintsTotal = hints && solhintEnabled && state.data && state.source !== null ? hints.length : 0
props.event.trigger('staticAnaysisWarning', [slitherTotal + ssaTotal + hintsTotal]) props.event.trigger('staticAnaysisWarning', [(slitherTotal + ssaTotal + hintsTotal) === 0 ? -1 : (slitherTotal + ssaTotal + hintsTotal)])
}, [solhintEnabled, basicEnabled, slitherEnabled, showSlither]) }, [solhintEnabled, basicEnabled, slitherEnabled, showSlither])
const handleSlitherEnabled = async () => { const handleSlitherEnabled = async () => {
@ -393,16 +398,20 @@ useEffect(() => {
const handleBasicEnabled = () => { const handleBasicEnabled = () => {
if (basicEnabled) { if (basicEnabled) {
setBasicEnabled(false) setBasicEnabled(false)
props.event.trigger('staticAnalysisWarning', [-1])
} else { } else {
setBasicEnabled(true) setBasicEnabled(true)
props.event.trigger('staticAnalysisWarning', [-1])
} }
} }
const handleLinterEnabled = () => { const handleLinterEnabled = () => {
if (solhintEnabled) { if (solhintEnabled) {
setSolhintEnabled(false) setSolhintEnabled(false)
props.event.trigger('staticAnalysisWarning', [-1])
} else { } else {
setSolhintEnabled(true) setSolhintEnabled(true)
props.event.trigger('staticAnalysisWarning', [-1])
} }
} }

Loading…
Cancel
Save