fixing case of incorrect badge total

pull/3838/head
Joseph Izang 1 year ago
parent bef549856a
commit f0720036e7
  1. 8
      apps/remix-ide/src/app/tabs/analysis-tab.js
  2. 39
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx
  3. 6
      libs/remix-ui/static-analyser/src/staticanalyser.d.ts

@ -58,7 +58,7 @@ class AnalysisTab extends ViewPlugin {
this.event.register('staticAnaysisWarning', (count) => {
let payloadType = ''
let totalCount = 0
// let totalCount = 0
this.hints && this.hints.length > 0 ? this.hints.forEach(hint => {
if (hint.type === 'error') {
payloadType = 'error'
@ -68,11 +68,7 @@ class AnalysisTab extends ViewPlugin {
}) : payloadType = 'warning'
if (count > 0) {
if (this.hints && this.hints.length > 0) {
totalCount = count === this.hints.length ? count : count + this.hints.length
}
totalCount += count
this.emit('statusChanged', { key: totalCount, title: `${totalCount} warning${totalCount === 1 ? '' : 's'}`, type: payloadType })
this.emit('statusChanged', { key: count, title: `${count} warning${count === 1 ? '' : 's'}`, type: payloadType })
} else if (count === 0) {
this.emit('statusChanged', { key: 'succeed', title: 'no warning', type: 'success' })
} else {

@ -196,6 +196,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
const slitherErrors = noLibSlitherWarnings.filter(slitherError => slitherError.options.type === 'error')
const remixAnalysisNoLibs = ssaWarnings.filter(ssa => ssa.options.isLibrary === false)
console.log({
hints, ssaWarnings, slitherWarnings, state
})
const message = (name: string, warning: any, more?: string, fileName?: string, locationString?: string) : string => {
return (`
<span className='d-flex flex-column'>
@ -230,12 +234,43 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}
}
}
if (newWarningCount > 0 && state.data && state.source !== null) {
props.event.trigger('staticAnaysisWarning', [newWarningCount])
if (ssaWarnings.length > 0 && state.data && state.source !== null) {
props.event.trigger('staticAnaysisWarning', [ssaWarnings.length])
setWarningState(newWarningState)
}
}
useEffect(() => {
if(solhintEnabled && basicEnabled) {
if(ssaWarnings.length > 0 && hints.length > 0) {
props.event.trigger('staticAnaysisWarning', [ssaWarnings.length + hints.length])
}
}
}, [showLibsWarning])
useEffect(() => {
if(basicEnabled && !solhintEnabled && !slitherEnabled && state.data && state.source !== null ) {
props.event.trigger('staticAnaysisWarning',
[hideWarnings ? remixAnalysisNoLibs.length : ssaWarnings.length])
}
if (solhintEnabled && !basicEnabled && !slitherEnabled && state.data && state.source !== null) {
props.event.trigger('staticAnaysisWarning', [hideWarnings ? hints.length : hintErrors.length])
}
if (solhintEnabled && basicEnabled && !slitherEnabled && state.data && state.source !== null) {
props.event.trigger('staticAnaysisWarning', [hideWarnings
? hintErrors.length + remixAnalysisNoLibs.length : hints.length + ssaWarnings.length])
}
if (slitherEnabled && !basicEnabled && !solhintEnabled && state.data && state.source !== null) {
props.event.trigger('staticAnaysisWarning', [hideWarnings ? slitherErrors.length : slitherWarnings.length])
}
if (slitherEnabled && basicEnabled && solhintEnabled && state.data && state.source !== null) {
props.event.trigger('staticAnaysisWarning', [hideWarnings
? hintErrors.length + remixAnalysisNoLibs.length + slitherErrors.length
: hints.length + ssaWarnings.length + slitherWarnings.length])
}
// props.event.trigger('staticAnaysisWarning', [-1])
}, [hideWarnings])
useEffect(() => {
if(hints.length > 0) {
props.event.trigger('staticAnaysisWarning', [hints.length])

@ -58,10 +58,10 @@ type RemixUiStaticAnalyserReducerActionType = {
interface ErrorRendererProps {
message: any;
opt: ErrorRendererOptions,
warningErrors: any
options: ErrorRendererOptions,
hasWarning: boolean,
editor: any,
name: string,
warningModuleName: string,
}
type ErrorRendererOptions = {

Loading…
Cancel
Save