diff --git a/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx b/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx index 5c0d8b57ad..0b051497c0 100644 --- a/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx +++ b/libs/remix-ui/static-analyser/src/lib/components/BasicTitle.tsx @@ -4,7 +4,7 @@ type BasicTitleProps = { warningStateEntries: any } -function calculateWarningStateEntries(entries: any[][]) { +export function calculateWarningStateEntries(entries: any[][]) { let warninglength = 0 entries.forEach((entry) => { warninglength += entry[1].length @@ -12,7 +12,7 @@ function calculateWarningStateEntries(entries: any[][]) { return warninglength } -export default function BasicTitle(props: BasicTitleProps) { +export function BasicTitle(props: BasicTitleProps) { return ( Basic{props.warningStateEntries.length > 0 ? {calculateWarningStateEntries(props.warningStateEntries)}: null} diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 769d84c836..0b45d36335 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -9,13 +9,11 @@ import ErrorRenderer from './ErrorRenderer' // eslint-disable-line import { compilation } from './actions/staticAnalysisActions' import { initialState, analysisReducer } from './reducers/staticAnalysisReducer' import { CodeAnalysis } from '@remix-project/remix-analyzer' -import { CustomTooltip } from '@remix-ui/helper' import Tab from 'react-bootstrap/Tab' import Tabs from 'react-bootstrap/Tabs' -import { Fade } from 'react-bootstrap' import { AnalysisTab, SolHintReport } from '../staticanalyser' import { run } from './actions/staticAnalysisActions' -import BasicTitle from './components/BasicTitle' +import { BasicTitle, calculateWarningStateEntries } from './components/BasicTitle' declare global { interface Window { @@ -158,6 +156,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { 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 props.analysisModule.on('solidity', 'compilerLoaded', async (version: string, license: string) => { setDisableForRun(version) @@ -268,6 +271,14 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } } + const handleLinterEnabled = () => { + if (solhintEnabled) { + setSolhintEnabled(false) + } else { + setSolhintEnabled(true) + } + } + const handleCheckSingle = (event, _index) => { _index = _index.toString() if (categoryIndex.includes(_index)) { @@ -344,10 +355,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { ) } - const handleShowLinterMessages = () => { - - } - const handleHideWarnings = () => { } @@ -359,7 +366,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { <> {hints.length > 0 &&
-
+
{ hints.map((hint, index) => ( @@ -401,11 +408,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { child: <> {Object.entries(warningState).length > 0 &&
-
+
{ (Object.entries(warningState).map((element, index) => (
- {element[1]['length'] > 0 ? {element[0]} : null} + {/* {element[1]['length'] > 0 ? {element[0]} : null} */} {element[1]['map']((x, i) => ( // eslint-disable-line dot-notation x.hasWarning ? ( // eslint-disable-next-line dot-notation
@@ -438,7 +445,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { id="solhintstaticanalysis" inputType="checkbox" title="Run solhint static analysis on file save" - onClick={handleShowLinterMessages} + onClick={handleLinterEnabled} checked={solhintEnabled} label="Linter" onChange={() => {}} @@ -454,7 +461,10 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { })) }).flat().every(el => categoryIndex.includes(el))} label="Basic" - onClick={() => handleCheckAllModules(groupedModules)} + onClick={() => { + handleBasicEnabled() + handleCheckAllModules(groupedModules) + }} onChange={() => {}} tooltipPlacement={'top-start'} /> @@ -509,17 +519,37 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { />
- - {tabKeys.map(tabKey => ( - + {solhintEnabled ? - {tabKey.child} - - ))} + {tabKeys[0].child} + : null} + + {basicEnabled ? + {tabKeys[1].child} + : null} + + { slitherEnabled ? + {tabKeys[2].child} + : null } +