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

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

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

Loading…
Cancel
Save