Commit ed4bff7e authored by aniket-engg's avatar aniket-engg Committed by Aniket

slither results on UI

parent bee567ac
...@@ -105,6 +105,27 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ...@@ -105,6 +105,27 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
) )
} }
const showWarnings = (warningMessage, groupByKey) => {
const resultArray = []
warningMessage.map(x => {
resultArray.push(x)
})
function groupBy (objectArray, property) {
return objectArray.reduce((acc, obj) => {
const key = obj[property]
if (!acc[key]) {
acc[key] = []
}
// Add object to list for given key's value
acc[key].push(obj)
return acc
}, {})
}
const groupedCategory = groupBy(resultArray, groupByKey)
setWarningState(groupedCategory)
}
const run = (lastCompilationResult, lastCompilationSource, currentFile) => { const run = (lastCompilationResult, lastCompilationSource, currentFile) => {
if (state.data !== null) { if (state.data !== null) {
if (lastCompilationResult && categoryIndex.length > 0) { if (lastCompilationResult && categoryIndex.length > 0) {
...@@ -112,7 +133,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ...@@ -112,7 +133,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
const warningMessage = [] const warningMessage = []
const warningErrors = [] const warningErrors = []
/******************** Remix Analyzer ********************/ /******************** Remix Analysis ********************/
runner.run(lastCompilationResult, categoryIndex, results => { runner.run(lastCompilationResult, categoryIndex, results => {
results.map((result) => { results.map((result) => {
let moduleName let moduleName
...@@ -166,15 +187,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ...@@ -166,15 +187,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName }) warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName })
}) })
}) })
}) /******************** Slither Analysis ********************/
/******************** Slither Analyzer Start ********************/
if (slitherEnabled) { if (slitherEnabled) {
props.analysisModule.call('solidity-logic', 'getCompilerState').then((compilerState) => { props.analysisModule.call('solidity-logic', 'getCompilerState').then((compilerState) => {
const { currentVersion, optimize, evmVersion } = compilerState const { currentVersion, optimize, evmVersion } = compilerState
props.analysisModule.call('slither', 'analyse', state.file, { currentVersion, optimize, evmVersion }).then((result) => { props.analysisModule.call('slither', 'analyse', state.file, { currentVersion, optimize, evmVersion }).then((result) => {
console.log('slither result')
if (result.status) { if (result.status) {
const report = result.data const report = result.data
report.map((item) => { report.map((item) => {
...@@ -209,7 +226,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ...@@ -209,7 +226,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
fileName, fileName,
errLine: row, errLine: row,
errCol: column, errCol: column,
item: item, item: { warning: item.description},
name: item.title, name: item.title,
locationString, locationString,
more: item.more, more: item.more,
...@@ -218,33 +235,12 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ...@@ -218,33 +235,12 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
warningErrors.push(options) warningErrors.push(options)
warningMessage.push({ msg, options, hasWarning: true, warningModuleName: item.title }) warningMessage.push({ msg, options, hasWarning: true, warningModuleName: item.title })
}) })
showWarnings(warningMessage, 'warningModuleName')
} }
const resultArray = []
warningMessage.map(x => {
resultArray.push(x)
}) })
function groupBy (objectArray, property) {
return objectArray.reduce((acc, obj) => {
const key = obj[property]
if (!acc[key]) {
acc[key] = []
}
// Add object to list for given key's value
acc[key].push(obj)
return acc
}, {})
}
const groupedCategory = groupBy(resultArray, 'warningModuleName')
setWarningState(groupedCategory)
}) })
} else showWarnings(warningMessage, 'warningModuleName')
}) })
}
/******************** Slither Analyzer Finish ********************/
if (categoryIndex.length > 0) { if (categoryIndex.length > 0) {
props.event.trigger('staticAnaysisWarning', [warningCount]) props.event.trigger('staticAnaysisWarning', [warningCount])
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment