|
|
@ -9,13 +9,11 @@ import ErrorRenderer from './ErrorRenderer' // eslint-disable-line |
|
|
|
import { compilation } from './actions/staticAnalysisActions' |
|
|
|
import { compilation } from './actions/staticAnalysisActions' |
|
|
|
import { initialState, analysisReducer } from './reducers/staticAnalysisReducer' |
|
|
|
import { initialState, analysisReducer } from './reducers/staticAnalysisReducer' |
|
|
|
import { CodeAnalysis } from '@remix-project/remix-analyzer' |
|
|
|
import { CodeAnalysis } from '@remix-project/remix-analyzer' |
|
|
|
import { CustomTooltip } from '@remix-ui/helper' |
|
|
|
|
|
|
|
import Tab from 'react-bootstrap/Tab' |
|
|
|
import Tab from 'react-bootstrap/Tab' |
|
|
|
import Tabs from 'react-bootstrap/Tabs' |
|
|
|
import Tabs from 'react-bootstrap/Tabs' |
|
|
|
import { Fade } from 'react-bootstrap' |
|
|
|
|
|
|
|
import { AnalysisTab, SolHintReport } from '../staticanalyser' |
|
|
|
import { AnalysisTab, SolHintReport } from '../staticanalyser' |
|
|
|
import { run } from './actions/staticAnalysisActions' |
|
|
|
import { run } from './actions/staticAnalysisActions' |
|
|
|
import BasicTitle from './components/BasicTitle' |
|
|
|
import { BasicTitle, calculateWarningStateEntries } from './components/BasicTitle' |
|
|
|
|
|
|
|
|
|
|
|
declare global { |
|
|
|
declare global { |
|
|
|
interface Window { |
|
|
|
interface Window { |
|
|
@ -158,6 +156,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
setSlitherEnabled(false) |
|
|
|
setSlitherEnabled(false) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
const warningResult = calculateWarningStateEntries(Object.entries(warningState)) |
|
|
|
|
|
|
|
console.log({ warningResult, hintCount: hints.length }) |
|
|
|
|
|
|
|
props.analysisModule.emit('statusChanged', 'solhint', { key: hints.length+warningResult,
|
|
|
|
|
|
|
|
title: `${hints.length+warningResult} warning${hints.length+warningResult === 1 ? '' : 's'}`, type: 'warning'}) |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [hints.length+warningResult]) |
|
|
|
// 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) |
|
|
@ -268,6 +271,14 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleLinterEnabled = () => { |
|
|
|
|
|
|
|
if (solhintEnabled) { |
|
|
|
|
|
|
|
setSolhintEnabled(false) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setSolhintEnabled(true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleCheckSingle = (event, _index) => { |
|
|
|
const handleCheckSingle = (event, _index) => { |
|
|
|
_index = _index.toString() |
|
|
|
_index = _index.toString() |
|
|
|
if (categoryIndex.includes(_index)) { |
|
|
|
if (categoryIndex.includes(_index)) { |
|
|
@ -344,10 +355,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleShowLinterMessages = () => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleHideWarnings = () => { |
|
|
|
const handleHideWarnings = () => { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -359,7 +366,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
<> |
|
|
|
<> |
|
|
|
{hints.length > 0 && |
|
|
|
{hints.length > 0 && |
|
|
|
<div id='solhintlintingresult' className="mb-5"> |
|
|
|
<div id='solhintlintingresult' className="mb-5"> |
|
|
|
<div className="mb-4"> |
|
|
|
<div className="mb-4 pt-2"> |
|
|
|
{ |
|
|
|
{ |
|
|
|
hints.map((hint, index) => ( |
|
|
|
hints.map((hint, index) => ( |
|
|
|
<Fragment key={index}> |
|
|
|
<Fragment key={index}> |
|
|
@ -401,11 +408,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
child: <> |
|
|
|
child: <> |
|
|
|
{Object.entries(warningState).length > 0 && |
|
|
|
{Object.entries(warningState).length > 0 && |
|
|
|
<div id='staticanalysisresult' > |
|
|
|
<div id='staticanalysisresult' > |
|
|
|
<div className="mb-4"> |
|
|
|
<div className="mb-4 pt-2"> |
|
|
|
{ |
|
|
|
{ |
|
|
|
(Object.entries(warningState).map((element, index) => ( |
|
|
|
(Object.entries(warningState).map((element, index) => ( |
|
|
|
<div key={index}> |
|
|
|
<div key={index}> |
|
|
|
{element[1]['length'] > 0 ? <span className="text-dark h6">{element[0]}</span> : null} |
|
|
|
{/* {element[1]['length'] > 0 ? <span className="text-dark h6">{element[0]}</span> : null} */} |
|
|
|
{element[1]['map']((x, i) => ( // eslint-disable-line dot-notation
|
|
|
|
{element[1]['map']((x, i) => ( // eslint-disable-line dot-notation
|
|
|
|
x.hasWarning ? ( // eslint-disable-next-line dot-notation
|
|
|
|
x.hasWarning ? ( // eslint-disable-next-line dot-notation
|
|
|
|
<div data-id={`staticAnalysisModule${x.warningModuleName}${i}`} id={`staticAnalysisModule${x.warningModuleName}${i}`} key={i}> |
|
|
|
<div data-id={`staticAnalysisModule${x.warningModuleName}${i}`} id={`staticAnalysisModule${x.warningModuleName}${i}`} key={i}> |
|
|
@ -438,7 +445,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
id="solhintstaticanalysis" |
|
|
|
id="solhintstaticanalysis" |
|
|
|
inputType="checkbox" |
|
|
|
inputType="checkbox" |
|
|
|
title="Run solhint static analysis on file save" |
|
|
|
title="Run solhint static analysis on file save" |
|
|
|
onClick={handleShowLinterMessages} |
|
|
|
onClick={handleLinterEnabled} |
|
|
|
checked={solhintEnabled} |
|
|
|
checked={solhintEnabled} |
|
|
|
label="Linter" |
|
|
|
label="Linter" |
|
|
|
onChange={() => {}} |
|
|
|
onChange={() => {}} |
|
|
@ -454,7 +461,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
})) |
|
|
|
})) |
|
|
|
}).flat().every(el => categoryIndex.includes(el))} |
|
|
|
}).flat().every(el => categoryIndex.includes(el))} |
|
|
|
label="Basic" |
|
|
|
label="Basic" |
|
|
|
onClick={() => handleCheckAllModules(groupedModules)} |
|
|
|
onClick={() => { |
|
|
|
|
|
|
|
handleBasicEnabled() |
|
|
|
|
|
|
|
handleCheckAllModules(groupedModules) |
|
|
|
|
|
|
|
}} |
|
|
|
onChange={() => {}} |
|
|
|
onChange={() => {}} |
|
|
|
tooltipPlacement={'top-start'} |
|
|
|
tooltipPlacement={'top-start'} |
|
|
|
/> |
|
|
|
/> |
|
|
@ -509,17 +519,37 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<Tabs fill defaultActiveKey={tabKeys[0].tabKey}> |
|
|
|
<Tabs defaultActiveKey={tabKeys[0].tabKey}> |
|
|
|
{tabKeys.map(tabKey => ( |
|
|
|
{solhintEnabled ? <Tab |
|
|
|
<Tab |
|
|
|
key={tabKeys[0].tabKey} |
|
|
|
key={tabKey.tabKey} |
|
|
|
disabled={solhintEnabled} |
|
|
|
title={tabKey.title} |
|
|
|
title={tabKeys[0].title} |
|
|
|
eventKey={tabKey.tabKey} |
|
|
|
eventKey={tabKeys[0].tabKey} |
|
|
|
tabClassName="text-decoration-none font-weight-bold" |
|
|
|
tabClassName="text-decoration-none font-weight-bold" |
|
|
|
> |
|
|
|
> |
|
|
|
{tabKey.child} |
|
|
|
{tabKeys[0].child} |
|
|
|
</Tab> |
|
|
|
</Tab> : null} |
|
|
|
))} |
|
|
|
|
|
|
|
|
|
|
|
{basicEnabled ? <Tab |
|
|
|
|
|
|
|
key={tabKeys[1].tabKey} |
|
|
|
|
|
|
|
disabled={basicEnabled} |
|
|
|
|
|
|
|
title={tabKeys[1].title} |
|
|
|
|
|
|
|
eventKey={tabKeys[1].tabKey} |
|
|
|
|
|
|
|
tabClassName="text-decoration-none font-weight-bold" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{tabKeys[1].child} |
|
|
|
|
|
|
|
</Tab> : null} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ slitherEnabled ? <Tab |
|
|
|
|
|
|
|
key={tabKeys[2].tabKey} |
|
|
|
|
|
|
|
disabled={slitherEnabled} |
|
|
|
|
|
|
|
title={tabKeys[2].title} |
|
|
|
|
|
|
|
eventKey={tabKeys[2].tabKey} |
|
|
|
|
|
|
|
tabClassName="text-decoration-none font-weight-bold" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{tabKeys[2].child} |
|
|
|
|
|
|
|
</Tab> : null } |
|
|
|
|
|
|
|
|
|
|
|
</Tabs> |
|
|
|
</Tabs> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|