|
|
@ -110,17 +110,19 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
compilation(props.analysisModule, dispatch) |
|
|
|
compilation(props.analysisModule, dispatch) |
|
|
|
}, [props]) |
|
|
|
}, [props]) |
|
|
|
|
|
|
|
|
|
|
|
// useEffect(() => {
|
|
|
|
useEffect(() => { |
|
|
|
// setWarningState({})
|
|
|
|
// setWarningState({})
|
|
|
|
// const runAnalysis = async () => {
|
|
|
|
// setHints([])
|
|
|
|
// 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, solhintEnabled)
|
|
|
|
// setSlitherWarnings([])
|
|
|
|
// }
|
|
|
|
// setSsaWarnings([])
|
|
|
|
// props.event.trigger('staticAnaysisWarning', [])
|
|
|
|
setStartAnalysis(false) |
|
|
|
// return () => { }
|
|
|
|
props.event.trigger('staticAnaysisWarning', [-1]) |
|
|
|
// }, [state])
|
|
|
|
return () => { } |
|
|
|
|
|
|
|
}, [state]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
props.analysisModule.call('solidity', 'getCompilerState').then((compilerState) => setDisableForRun(compilerState.currentVersion)) |
|
|
|
props.analysisModule.call('solidity', 'getCompilerState').then((compilerState) => setDisableForRun(compilerState.currentVersion)) |
|
|
|
|
|
|
|
props.event.trigger('staticAnalysisWarning', [-1]) |
|
|
|
}, []) |
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
@ -132,6 +134,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
checkRemixdActive() |
|
|
|
checkRemixdActive() |
|
|
|
|
|
|
|
props.event.trigger('staticAnalysisWarning', [-1]) |
|
|
|
}, [props]) |
|
|
|
}, [props]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
@ -165,7 +168,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
setSlitherEnabled(false) |
|
|
|
setSlitherEnabled(false) |
|
|
|
setSsaWarnings([]) |
|
|
|
setSsaWarnings([]) |
|
|
|
// Reset badge
|
|
|
|
// Reset badge
|
|
|
|
props.event.trigger('staticAnaysisWarning', []) |
|
|
|
props.event.trigger('staticAnalysisWarning', [-1]) |
|
|
|
// Reset state
|
|
|
|
// Reset state
|
|
|
|
dispatch({ type: '', payload: initialState }) |
|
|
|
dispatch({ type: '', payload: initialState }) |
|
|
|
setShowSlither(false) |
|
|
|
setShowSlither(false) |
|
|
@ -174,6 +177,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
props.analysisModule.on('solidity', 'compilerLoaded', async (version: string, license: string) => { |
|
|
|
props.analysisModule.on('solidity', 'compilerLoaded', async (version: string, license: string) => { |
|
|
|
setDisableForRun(version) |
|
|
|
setDisableForRun(version) |
|
|
|
|
|
|
|
props.event.trigger('staticAnalysisWarning', [-1]) |
|
|
|
}) |
|
|
|
}) |
|
|
|
return () => { } |
|
|
|
return () => { } |
|
|
|
}, [props]) |
|
|
|
}, [props]) |
|
|
@ -337,11 +341,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
//#endregion
|
|
|
|
//#endregion
|
|
|
|
// useEffect(() => {
|
|
|
|
|
|
|
|
// if(hints.length > 0) {
|
|
|
|
|
|
|
|
// props.event.trigger('staticAnaysisWarning', [hints.length])
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// },[hints.length])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if(!hideWarnings && !showLibsWarning) { |
|
|
|
if(!hideWarnings && !showLibsWarning) { |
|
|
@ -379,17 +378,17 @@ useEffect(() => { |
|
|
|
props.event.trigger('staticAnaysisWarning', [slitherTotal + ssaTotal + hintsTotal]) |
|
|
|
props.event.trigger('staticAnaysisWarning', [slitherTotal + ssaTotal + hintsTotal]) |
|
|
|
}, [hints.length, slitherWarnings.length, ssaWarnings.length]) |
|
|
|
}, [hints.length, slitherWarnings.length, ssaWarnings.length]) |
|
|
|
|
|
|
|
|
|
|
|
// useEffect(() => {
|
|
|
|
useEffect(() => { |
|
|
|
// const slitherTotal = slitherWarnings && slitherEnabled && showSlither && state.data && state.source !== null
|
|
|
|
const slitherTotal = slitherWarnings && slitherEnabled && showSlither && state.data && state.source !== null |
|
|
|
// ? slitherWarnings.filter((x) => !x.options.isLibrary && x.hasWarning).length
|
|
|
|
? slitherWarnings.filter((x) => !x.options.isLibrary && x.hasWarning).length |
|
|
|
// : 0
|
|
|
|
: 0 |
|
|
|
// const ssaTotal = ssaWarnings && basicEnabled && state.data && state.source !== null
|
|
|
|
const ssaTotal = ssaWarnings && basicEnabled && state.data && state.source !== null |
|
|
|
// ? 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 |
|
|
|
// console.log('hideWarnings & showLibsWarning are unchecked and tools could be checked or unchecked', { slitherTotal, ssaTotal, hintsTotal })
|
|
|
|
console.log('hideWarnings & showLibsWarning are unchecked and tools could be checked or unchecked', { slitherTotal, ssaTotal, hintsTotal }) |
|
|
|
// props.event.trigger('staticAnaysisWarning', [slitherTotal + ssaTotal + hintsTotal])
|
|
|
|
props.event.trigger('staticAnaysisWarning', [slitherTotal + ssaTotal + hintsTotal]) |
|
|
|
// }, [solhintEnabled, basicEnabled, slitherEnabled, showSlither])
|
|
|
|
}, [solhintEnabled, basicEnabled, slitherEnabled, showSlither]) |
|
|
|
|
|
|
|
|
|
|
|
const handleSlitherEnabled = async () => { |
|
|
|
const handleSlitherEnabled = async () => { |
|
|
|
const checkRemixd = await props.analysisModule.call('manager', 'isActive', 'remixd') |
|
|
|
const checkRemixd = await props.analysisModule.call('manager', 'isActive', 'remixd') |
|
|
@ -529,7 +528,7 @@ useEffect(() => { |
|
|
|
), |
|
|
|
), |
|
|
|
title: ( |
|
|
|
title: ( |
|
|
|
<span> |
|
|
|
<span> |
|
|
|
Linter |
|
|
|
Solhint |
|
|
|
{hints.length > 0 ? ( |
|
|
|
{hints.length > 0 ? ( |
|
|
|
hideWarnings ? ( |
|
|
|
hideWarnings ? ( |
|
|
|
<i className={`badge ${hints.filter(x => x.type === 'error').length > 0 |
|
|
|
<i className={`badge ${hints.filter(x => x.type === 'error').length > 0 |
|
|
@ -561,10 +560,9 @@ useEffect(() => { |
|
|
|
{Object.entries(warningState).length > 0 ? ( |
|
|
|
{Object.entries(warningState).length > 0 ? ( |
|
|
|
<div id="staticanalysisresult"> |
|
|
|
<div id="staticanalysisresult"> |
|
|
|
<div className="mb-4 pt-2"> |
|
|
|
<div className="mb-4 pt-2"> |
|
|
|
{Object.entries(warningState).map((element, index) => ( |
|
|
|
<div> |
|
|
|
<div key={index}> |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
!hideWarnings && !showLibsWarning && ssaWarnings.length > 0 ? ssaWarnings.filter(x => !x.options.isLibrary).map((x, i) => ( |
|
|
|
!hideWarnings && !showLibsWarning && ssaWarnings.length > 0 ? ssaWarnings.filter(x => !x.options.isLibrary && x.hasWarning).map((x, i) => ( |
|
|
|
<div |
|
|
|
<div |
|
|
|
data-id={`staticAnalysisModule${x.warningModuleName}${i}`} |
|
|
|
data-id={`staticAnalysisModule${x.warningModuleName}${i}`} |
|
|
|
id={`staticAnalysisModule${x.warningModuleName}${i}`} |
|
|
|
id={`staticAnalysisModule${x.warningModuleName}${i}`} |
|
|
@ -595,7 +593,6 @@ useEffect(() => { |
|
|
|
)) : null |
|
|
|
)) : null |
|
|
|
} |
|
|
|
} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
))} |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) : state.data && state.file.length > 0 && state.source && startAnalysis && Object.entries(warningState).length > 0 ? <span className="ml-4 spinner-grow-sm d-flex justify-content-center">Loading...</span> : <span className="display-6 text-center">Nothing to report</span>} |
|
|
|
) : state.data && state.file.length > 0 && state.source && startAnalysis && Object.entries(warningState).length > 0 ? <span className="ml-4 spinner-grow-sm d-flex justify-content-center">Loading...</span> : <span className="display-6 text-center">Nothing to report</span>} |
|
|
|