pull/3892/head
Joseph Izang 1 year ago
parent b6a0b02ba3
commit 23e6620670
  1. 48
      libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx
  2. 3
      libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts
  3. 4
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -1,6 +1,6 @@
import { CustomTooltip } from "@remix-ui/helper";
import { CustomTooltip } from "@remix-ui/helper"
import React from "react"; //eslint-disable-line
import { RemixUiStaticAnalyserState } from "../staticanalyser";
import { RemixUiStaticAnalyserState } from "../staticanalyser"
interface ErrorRendererProps {
message: any;
@ -13,45 +13,45 @@ interface ErrorRendererProps {
const ErrorRenderer = ({ message, opt, editor, name, ssaState }: ErrorRendererProps) => {
const getPositionDetails = (msg: any) => {
const result = {} as Record<string, number | string>;
const result = {} as Record<string, number | string>
// To handle some compiler warning without location like SPDX license warning etc
if (!msg.includes(":")) return { errLine: -1, errCol: -1, errFile: msg };
if (!msg.includes(":")) return { errLine: -1, errCol: -1, errFile: msg }
// extract line / column
let position = msg.match(/^(.*?):([0-9]*?):([0-9]*?)?/);
result.errLine = position ? parseInt(position[2]) - 1 : -1;
result.errCol = position ? parseInt(position[3]) : -1;
let position = msg.match(/^(.*?):([0-9]*?):([0-9]*?)?/)
result.errLine = position ? parseInt(position[2]) - 1 : -1
result.errCol = position ? parseInt(position[3]) : -1
// extract file
position = msg.match(/^(https:.*?|http:.*?|.*?):/);
result.errFile = position ? position[1] : "";
position = msg.match(/^(https:.*?|http:.*?|.*?):/)
result.errFile = position ? position[1] : ""
return result;
};
}
const handlePointToErrorOnClick = async (location, fileName) => {
await editor.call("editor", "discardHighlight");
await editor.call("editor", "discardHighlight")
await editor.call("editor", "highlight", location, fileName, "", {
focus: true,
});
};
})
}
if (!message) return;
let position = getPositionDetails(message);
if (!message) return
let position = getPositionDetails(message)
if (
!position.errFile ||
(opt.errorType && opt.errorType === position.errFile)
) {
// Updated error reported includes '-->' before file details
const errorDetails = message.split("-->");
const errorDetails = message.split("-->")
// errorDetails[1] will have file details
if (errorDetails.length > 1) position = getPositionDetails(errorDetails[1]);
if (errorDetails.length > 1) position = getPositionDetails(errorDetails[1])
}
opt.errLine = position.errLine;
opt.errCol = position.errCol;
opt.errFile = position.errFile.trim();
opt.errLine = position.errLine
opt.errCol = position.errCol
opt.errFile = position.errFile.trim()
const classList =
opt.type === "error" ? "alert alert-danger" : "alert alert-warning";
opt.type === "error" ? "alert alert-danger" : "alert alert-warning"
return (
<div>
<div className={`sol ${opt.type} ${classList}`}>
@ -91,7 +91,7 @@ const ErrorRenderer = ({ message, opt, editor, name, ssaState }: ErrorRendererPr
</div>
</div>
</div>
);
};
)
}
export default ErrorRenderer;
export default ErrorRenderer

@ -207,8 +207,7 @@ slitherEnabled: boolean, setStartAnalysis: React.Dispatch<React.SetStateAction<b
props.analysisModule.call('terminal', 'log', { type: 'error', value: '[Slither Analysis]: Error occured! See remixd console for details.' })
showWarnings(warningMessage, 'warningModuleName')
}
} else //showWarnings(warningMessage, 'warningModuleName')
setStartAnalysis(false)
} else setStartAnalysis(false)
} else {
if (categoryIndex.length) {
warningContainer.current.innerText = 'No compiled AST available'

@ -528,10 +528,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
])
}, [solhintEnabled, basicEnabled, slitherEnabled, showSlither])
useEffect(() => {
}, [])
const handleSlitherEnabled = async () => {
const checkRemixd = await props.analysisModule.call(
"manager",

Loading…
Cancel
Save