|
|
@ -135,6 +135,13 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
props.analysisModule.call('solidity', 'getCompilerState').then((compilerState) => setDisableForRun(compilerState.currentVersion)) |
|
|
|
props.analysisModule.call('solidity', 'getCompilerState').then((compilerState) => setDisableForRun(compilerState.currentVersion)) |
|
|
|
}, []) |
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
props.analysisModule.on('solidity', 'compilationFinished', (file, source, languageVersion, data) => { |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [-1]) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return () => { props.event.trigger('staticAnalysisWarning', [-1]) } |
|
|
|
|
|
|
|
}, [state.data, state.source]) |
|
|
|
|
|
|
|
|
|
|
|
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') |
|
|
@ -239,72 +246,65 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
// if hideWarnings is true
|
|
|
|
// if hideWarnings is true
|
|
|
|
if(basicEnabled && !solhintEnabled && !slitherEnabled && state.data && state.source !== null ) { |
|
|
|
if(basicEnabled && hideWarnings && !solhintEnabled && !slitherEnabled && state.data && state.source !== null ) { |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', |
|
|
|
props.event.trigger('staticAnaysisWarning', |
|
|
|
[hideWarnings ? remixAnalysisLessWarnings.length : ssaWarnings.length]) |
|
|
|
[hideWarnings ? remixAnalysisLessWarnings.length : remixAnalysisNoLibs.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
if (solhintEnabled && !basicEnabled && !slitherEnabled && state.data && state.source !== null) { |
|
|
|
if (solhintEnabled && hideWarnings && !basicEnabled && !slitherEnabled && state.data && state.source !== null) { |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [hideWarnings ? hintErrors.length : hints?.length]) |
|
|
|
props.event.trigger('staticAnaysisWarning', [hideWarnings ? hintErrors.length : hints?.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
if (solhintEnabled && basicEnabled && !slitherEnabled && !showLibsWarning |
|
|
|
if (solhintEnabled && basicEnabled && hideWarnings && !slitherEnabled && !showLibsWarning |
|
|
|
&& state.data && state.source !== null) { |
|
|
|
&& state.data && state.source !== null) { |
|
|
|
console.log('solhint and remix are enabled here') |
|
|
|
console.log('solhint and remix are enabled here') |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [hideWarnings |
|
|
|
props.event.trigger('staticAnaysisWarning', [hideWarnings |
|
|
|
? hintErrors.length + remixAnalysisNoLibs.filter(x => x.options.type !== 'warning').length : hints?.length + ssaWarnings.length]) |
|
|
|
? hintErrors.length + remixAnalysisNoLibs.filter(x => x.options.type !== 'warning').length : hints?.length + remixAnalysisNoLibs.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
if (slitherEnabled && !basicEnabled && !solhintEnabled && state.data && state.source !== null) { |
|
|
|
if (slitherEnabled && hideWarnings && !basicEnabled && !solhintEnabled && state.data && state.source !== null) { |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [hideWarnings ? slitherErrors.length : slitherWarnings.length]) |
|
|
|
props.event.trigger('staticAnaysisWarning', [hideWarnings ? slitherErrors.length : slitherWarnings.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
if (slitherEnabled && basicEnabled && solhintEnabled && state.data && state.source !== null) { |
|
|
|
if (slitherEnabled && basicEnabled && solhintEnabled && hideWarnings && state.data && state.source !== null) { |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [hideWarnings |
|
|
|
props.event.trigger('staticAnaysisWarning', [hideWarnings |
|
|
|
? hintErrors.length + remixAnalysisLessWarnings.length + slitherErrors.length |
|
|
|
? hintErrors.length + remixAnalysisLessWarnings.length + slitherErrors.length |
|
|
|
: hints?.length + ssaWarnings.length + slitherWarnings.length]) |
|
|
|
: hints?.length + ssaWarnings.length + slitherWarnings.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, [hideWarnings, state]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
// if showLibsWarning is true
|
|
|
|
// if showLibsWarning is true
|
|
|
|
if(basicEnabled && !solhintEnabled && !slitherEnabled && !hideWarnings && state.data && state.source !== null ) { |
|
|
|
if(basicEnabled && !solhintEnabled && !slitherEnabled && !hideWarnings && state.data && state.source !== null ) { |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', |
|
|
|
props.event.trigger('staticAnaysisWarning', |
|
|
|
[showLibsWarning ? ssaWarnings.length : remixAnalysisNoLibs.length]) |
|
|
|
[showLibsWarning ? ssaWarnings.length : remixAnalysisNoLibs.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
if (solhintEnabled && !basicEnabled && !slitherEnabled && !hideWarnings && state.data && state.source !== null) { |
|
|
|
if (solhintEnabled && !basicEnabled && !slitherEnabled && !hideWarnings && state.data && state.source !== null) { |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [showLibsWarning ? hints?.length : hints?.length]) |
|
|
|
props.event.trigger('staticAnaysisWarning', [showLibsWarning ? hints?.length : hints?.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
if (solhintEnabled && basicEnabled && !slitherEnabled && !hideWarnings && state.data && state.source !== null) { |
|
|
|
if (solhintEnabled && basicEnabled && !slitherEnabled && !hideWarnings && state.data && state.source !== null && state.data && state.source !== null) { |
|
|
|
console.log('solhint and remix are enabled here') |
|
|
|
|
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [showLibsWarning |
|
|
|
props.event.trigger('staticAnaysisWarning', [showLibsWarning |
|
|
|
? hints?.length + ssaWarnings.length : hints?.length + remixAnalysisNoLibs.length]) |
|
|
|
? hints?.length + ssaWarnings.length : hints?.length + remixAnalysisNoLibs.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
if (slitherEnabled && !basicEnabled && !solhintEnabled && !hideWarnings && state.data && state.source !== null) { |
|
|
|
if (slitherEnabled && !basicEnabled && !solhintEnabled && !hideWarnings && state.data && state.source !== null && state.data && state.source !== null) { |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [showLibsWarning && noLibSlitherWarnings.length]) |
|
|
|
props.event.trigger('staticAnaysisWarning', [showLibsWarning && noLibSlitherWarnings.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
if (slitherEnabled && basicEnabled && solhintEnabled && !hideWarnings && state.data && state.source !== null) { |
|
|
|
if (slitherEnabled && basicEnabled && solhintEnabled && !hideWarnings && state.data && state.source !== null && state.data && state.source !== null) { |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [showLibsWarning |
|
|
|
props.event.trigger('staticAnaysisWarning', [showLibsWarning |
|
|
|
? hints?.length + ssaWarnings.length + slitherWarnings.length : hints?.length + remixAnalysisNoLibs.length + noLibSlitherWarnings.length]) |
|
|
|
? hints?.length + ssaWarnings.length + slitherWarnings.length : hints?.length + remixAnalysisNoLibs.length + noLibSlitherWarnings.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
if(basicEnabled && solhintEnabled && !slitherEnabled && !hideWarnings && !showLibsWarning) { |
|
|
|
}, [showLibsWarning, state]) |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if(basicEnabled && solhintEnabled && !slitherEnabled && !hideWarnings && !showLibsWarning && state.data && state.source !== null) { |
|
|
|
props.event.trigger('staticAnaysisWarning', [hints?.length + remixAnalysisNoLibs.length]) |
|
|
|
props.event.trigger('staticAnaysisWarning', [hints?.length + remixAnalysisNoLibs.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(solhintEnabled && basicEnabled && slitherEnabled && !hideWarnings && !showLibsWarning) { |
|
|
|
if(solhintEnabled && basicEnabled && slitherEnabled && !hideWarnings && !showLibsWarning && state.data && state.source !== null) { |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.analysisModule.hints = [] |
|
|
|
props.analysisModule.hints = [] |
|
|
|
props.event.trigger('staticAnaysisWarning', [hints?.length + remixAnalysisNoLibs.length + slitherWarnings.length]) |
|
|
|
props.event.trigger('staticAnaysisWarning', [hints?.length + remixAnalysisNoLibs.length + slitherWarnings.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
if(solhintEnabled && basicEnabled && !slitherEnabled && hideWarnings && showLibsWarning) { |
|
|
|
if(solhintEnabled && basicEnabled && !slitherEnabled && hideWarnings && showLibsWarning && state.data && state.source !== null) { |
|
|
|
props.analysisModule.internalCount = 0 |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [hintErrors.length + remixAnalysisLessWarnings.length]) |
|
|
|
props.event.trigger('staticAnaysisWarning', [hintErrors.length + remixAnalysisLessWarnings.length]) |
|
|
|
} |
|
|
|
} |
|
|
|
}, [ssaWarnings.length, hints?.length, hideWarnings, showLibsWarning, state]) |
|
|
|
// props.event.trigger('staticAnaysisWarning', [-1])
|
|
|
|
|
|
|
|
}, [ssaWarnings.length, remixAnalysisNoLibs.length, remixAnalysisLessWarnings.length, hints?.length, hintErrors?.length, state, state.data, state.source]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if(solhintEnabled === false) { |
|
|
|
if(solhintEnabled === false) { |
|
|
@ -312,6 +312,14 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
}, [solhintEnabled]) |
|
|
|
}, [solhintEnabled]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if(solhintEnabled && basicEnabled) { |
|
|
|
|
|
|
|
if(ssaWarnings.length > 0 && hints.length > 0) { |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [ssaWarnings.length + hints.length]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, [showLibsWarning]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const showWarnings = (warningMessage, groupByKey) => { |
|
|
|
const showWarnings = (warningMessage, groupByKey) => { |
|
|
@ -381,7 +389,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleLinterEnabled = async () => { |
|
|
|
const handleLinterEnabled = () => { |
|
|
|
if (solhintEnabled) { |
|
|
|
if (solhintEnabled) { |
|
|
|
setSolhintEnabled(false) |
|
|
|
setSolhintEnabled(false) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -591,6 +599,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
ssaWarnings={ssaWarnings} |
|
|
|
ssaWarnings={ssaWarnings} |
|
|
|
ssaWarningsNoLibs={remixAnalysisNoLibs} |
|
|
|
ssaWarningsNoLibs={remixAnalysisNoLibs} |
|
|
|
warningStateEntries={Object.entries(warningState)} |
|
|
|
warningStateEntries={Object.entries(warningState)} |
|
|
|
|
|
|
|
ssaWarningsNoLibsTotal={remixAnalysisNoLibs.length} |
|
|
|
|
|
|
|
ssaWarningsTotal={ssaWarnings.length} |
|
|
|
/> |
|
|
|
/> |
|
|
|
), |
|
|
|
), |
|
|
|
child: ( |
|
|
|
child: ( |
|
|
@ -705,12 +715,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
id="checkAllEntries" |
|
|
|
id="checkAllEntries" |
|
|
|
inputType="checkbox" |
|
|
|
inputType="checkbox" |
|
|
|
title="Remix analysis runs a basic analysis." |
|
|
|
title="Remix analysis runs a basic analysis." |
|
|
|
// checked={Object.values(groupedModules).map((value: any) => {
|
|
|
|
checked={basicEnabled && Object.values(groupedModules).map((value: any) => { |
|
|
|
// return (value.map(x => {
|
|
|
|
return (value.map(x => { |
|
|
|
// return x._index.toString()
|
|
|
|
return x._index.toString() |
|
|
|
// }))
|
|
|
|
})) |
|
|
|
// }).flat().every(el => categoryIndex.includes(el))}
|
|
|
|
}).flat().every(el => categoryIndex.includes(el))} |
|
|
|
checked={basicEnabled} |
|
|
|
|
|
|
|
onClick={handleBasicEnabled} |
|
|
|
onClick={handleBasicEnabled} |
|
|
|
label="Remix" |
|
|
|
label="Remix" |
|
|
|
onChange={() => {}} |
|
|
|
onChange={() => {}} |
|
|
|