fix bug where passing empty [] causes double eval

pull/5370/head
Joseph Izang 1 year ago
parent 56a8111205
commit 5892af9af1
  1. 13
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -3,6 +3,7 @@
import React, { useEffect, useState, useReducer, useRef, Fragment } from 'react' // eslint-disable-line import React, { useEffect, useState, useReducer, useRef, Fragment } from 'react' // eslint-disable-line
import Button from './Button/StaticAnalyserButton' // eslint-disable-line import Button from './Button/StaticAnalyserButton' // eslint-disable-line
import { util } from '@remix-project/remix-lib' import { util } from '@remix-project/remix-lib'
import { Status } from '@remixproject/plugin-utils'
import _ from 'lodash' import _ from 'lodash'
import * as semver from 'semver' import * as semver from 'semver'
import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line
@ -126,7 +127,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
const runAnalysis = async () => { 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) 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', []) props.event.trigger('staticAnaysisWarning', [0])
return () => { } return () => { }
}, [state]) }, [state])
@ -145,13 +146,19 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
checkRemixdActive() checkRemixdActive()
}, [props]) }, [props])
useEffect(() => {
if(hints.length > 0) {
props.event.trigger('staticAnaysisWarning', [hints.length])
}
}, [hints.length])
useEffect(() => { useEffect(() => {
props.analysisModule.on('filePanel', 'setWorkspace', (currentWorkspace) => { props.analysisModule.on('filePanel', 'setWorkspace', (currentWorkspace) => {
// Reset warning state // Reset warning state
allWarnings.current = {} allWarnings.current = {}
setWarningState({}) setWarningState({})
// Reset badge // Reset badge
props.event.trigger('staticAnaysisWarning', []) props.event.trigger('staticAnaysisWarning', [0])
// Reset state // Reset state
dispatch({ type: '', payload: initialState }) dispatch({ type: '', payload: initialState })
setHints([]) setHints([])
@ -177,7 +184,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
setSlitherEnabled(false) setSlitherEnabled(false)
setSsaWarnings([]) setSsaWarnings([])
// Reset badge // Reset badge
props.event.trigger('staticAnaysisWarning', []) props.event.trigger('staticAnaysisWarning', [0])
// Reset state // Reset state
dispatch({ type: '', payload: initialState }) dispatch({ type: '', payload: initialState })
setShowSlither(false) setShowSlither(false)

Loading…
Cancel
Save