fix failing test

pull/1104/head
tizah 4 years ago
parent 845cb3bc3c
commit 18cb9d4742
  1. 17
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -81,20 +81,25 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
const [warningState, setWarningState] = useState([])
useEffect(() => {
if (autoRun) {
const setCompilationResult = async (data, source, file) => {
await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file })
}
if (props.analysisModule) {
props.analysisModule.on(
'solidity',
'compilationFinished',
(file, source, languageVersion, data) => {
if (languageVersion.indexOf('soljson') !== 0) return
setCompilationResult(data, source, file)
if(categoryIndex.length > 0){
run(data, source, file)
}
}
)
}
} else {
@ -102,7 +107,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}
return () => { }
}, [autoRun])
}, [autoRun, categoryIndex])
const run = (lastCompilationResult, lastCompilationSource, currentFile) => {
// const highlightLocation = async (location, fileName) => {
@ -197,8 +202,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
const groupedCategory = groupBy(resultArray, 'warningModuleName')
setWarningState(groupedCategory)
})
if(categoryIndex.length > 0){
props.event.trigger('staticAnaysisWarning', [warningCount])
}
} else {
setRunButtonState(true)
if (categoryIndex.length) {
@ -217,8 +223,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
})
)
} else {
setCategoryIndex(_.uniq([...categoryIndex, ...index]))
setCategoryIndex(_.uniq([...categoryIndex]))
}
}
const handleCheckOrUncheckCategory = (category) => {
@ -353,9 +360,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
{result.currentFile && result.currentFile}
</span>
</div>
{ Object.entries(warningState).length > 0 &&
{ categoryIndex.length > 0 && Object.entries(warningState).length > 0 &&
<div id='staticanalysisresult' >
<div className="mb-4 warning">
<div className="mb-4">
{
(Object.entries(warningState).map((element) => (
<>

Loading…
Cancel
Save