@ -29,6 +29,7 @@ import {
calculateWarningStateEntries ,
} from "./components/BasicTitle" ;
import { Nav , TabContainer } from "react-bootstrap" ;
import { CustomTooltip } from "@remix-ui/helper" ;
declare global {
interface Window {
@ -365,8 +366,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
onChange = { ( ) = > { } }
/ >
< / div >
)
}
) ;
} ;
const categorySection = ( category , categoryId , i ) = > {
return (
@ -416,8 +417,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
< / TreeView >
< / div >
< / div >
)
}
) ;
} ;
useEffect ( ( ) = > {
if ( ! hideWarnings && ! showLibsWarning ) {
@ -436,85 +437,95 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
props . event . trigger ( "staticAnaysisWarning" , [
slitherTotal + ssaTotal + hintsTotal === 0
? - 1
: slitherTotal + ssaTotal + hintsTotal ,
] )
: ! solhintEnabled && ! basicEnabled && ! slitherEnabled ? - 1 : slitherTotal + ssaTotal + hintsTotal ,
] ) ;
}
if ( ! hideWarnings && showLibsWarning ) {
props . event . trigger ( "staticAnaysisWarning" , [
slitherWarnings . length + ssaWarnings . length + hints . length === 0
? - 1
: slitherWarnings . length + ssaWarnings . length + hints . length ,
] )
: ! solhintEnabled && ! basicEnabled && ! slitherEnabled ? - 1 : slitherWarnings. length + ssaWarnings . length + hints . length ,
] ) ;
}
if ( hideWarnings ) {
const slitherTotal =
slitherWarnings && state . data && state . source !== null
? slitherWarnings . filter ( ( x ) = > x . options . type === "error" ) . length
: 0
: 0 ;
const ssaTotal =
ssaWarnings && state . data && state . source !== null
? ssaWarnings . filter ( ( x ) = > x . options . type === "error" ) . length
: 0
: 0 ;
const hintsTotal =
hints && state . data && state . source !== null
? hints . filter ( ( x ) = > x . type === "error" ) . length
: 0
: 0 ;
props . event . trigger ( "staticAnaysisWarning" , [
slitherTotal + ssaTotal + hintsTotal === 0
? - 1
: slitherTotal + ssaTotal + hintsTotal ,
] )
] ) ;
}
if ( hideWarnings && ! solhintEnabled && ! slitherEnabled && ! basicEnabled ) {
props . event . trigger ( "staticAnaysisWarning" , [ - 1 ] )
}
} , [ hideWarnings , showLibsWarning ] )
useEffect ( ( ) = > {
cons t slitherTotal =
slitherEnabled &&
le t slitherTotal = 0
if ( slitherEnabled &&
showSlither &&
slitherWarnings &&
state . data &&
state . source !== null
? slitherWarnings . filter ( ( x ) = > ! x . options . isLibrary && x . hasWarning )
. length
: 0
const ssaTotal =
basicEnabled && ssaWarnings && state . data && state . source !== null
? ssaWarnings . filter ( ( x ) = > ! x . options . isLibrary && x . hasWarning ) . length
: 0
const hintsTotal =
solhintEnabled && hints && state . data && state . source !== null
? hints . length
: 0
state . source !== null ) {
slitherTotal = slitherWarnings . filter ( ( x ) = > ! x . options . isLibrary && x . hasWarning ) . length
props . analysisModule . slitherEnabled = true
}
let ssaTotal = 0
if ( basicEnabled && ssaWarnings && state . data && state . source !== null ) {
ssaTotal = ssaWarnings . filter ( ( x ) = > ! x . options . isLibrary && x . hasWarning ) . length
props . analysisModule . basicEnabled = true
}
let hintsTotal = 0
if ( solhintEnabled && hints && state . data && state . source !== null ) {
hintsTotal = hints . length
props . analysisModule . solhintEnabled = true
}
props . event . trigger ( "staticAnaysisWarning" , [
slitherTotal + ssaTotal + hintsTotal === 0
? - 1
: slitherTotal + ssaTotal + hintsTotal ,
] )
] ) ;
} , [ hints . length , slitherWarnings . length , ssaWarnings . length ] )
useEffect ( ( ) = > {
cons t slitherTotal =
slitherWarnings &&
le t slitherTotal = 0
if ( slitherWarnings &&
slitherEnabled &&
showSlither &&
state . data &&
state . source !== null
? slitherWarnings . filter ( ( x ) = > ! x . options . isLibrary && x . hasWarning )
. length
: 0
const ssaTotal =
ssaWarnings && basicEnabled && state . data && state . source !== null
? ssaWarnings . filter ( ( x ) = > ! x . options . isLibrary && x . hasWarning ) . length
: 0
const hintsTotal =
hints && solhintEnabled && state . data && state . source !== null
? hints . length
: 0
state . source !== null ) {
slitherTotal = slitherWarnings . filter ( ( x ) = > ! x . options . isLibrary && x . hasWarning )
. length
props . analysisModule . slitherEnabled = true
}
let ssaTotal = 0
if ( ssaWarnings && basicEnabled && state . data && state . source !== null ) {
ssaTotal = ssaWarnings . filter ( ( x ) = > ! x . options . isLibrary && x . hasWarning ) . length
props . analysisModule . basicEnabled = true
}
let hintsTotal = 0
if ( hints && solhintEnabled && state . data && state . source !== null ) {
hintsTotal = hints . length
}
props . event . trigger ( "staticAnaysisWarning" , [
slitherTotal + ssaTotal + hintsTotal === 0
? - 1
: slitherTotal + ssaTotal + hintsTotal ,
] ) ;
] )
} , [ solhintEnabled , basicEnabled , slitherEnabled , showSlither ] )
const handleSlitherEnabled = async ( ) = > {
@ -524,36 +535,42 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
"remixd"
) ;
if ( showSlither ) {
setShowSlither ( false ) ;
setShowSlither ( false )
props . analysisModule . slitherEnabled = false
}
if ( ! showSlither ) {
setShowSlither ( true ) ;
setShowSlither ( true )
props . analysisModule . slitherEnabled = true
}
} ;
const handleBasicEnabled = ( ) = > {
if ( basicEnabled ) {
setBasicEnabled ( false ) ;
setBasicEnabled ( false )
props . analysisModule . basicEnabled = false
if ( solhintEnabled ) {
setSelectedTab ( "solhint" ) ;
setSelectedTab ( "solhint" )
}
props . event . trigger ( "staticAnalysisWarning" , [ - 1 ] ) ;
props . event . trigger ( "staticAnalysisWarning" , [ - 1 ] )
} else {
setBasicEnabled ( true ) ;
props . event . trigger ( "staticAnalysisWarning" , [ - 1 ] ) ;
setBasicEnabled ( true )
props . analysisModule . basicEnabled = true
props . event . trigger ( "staticAnalysisWarning" , [ - 1 ] )
}
} ;
const handleLinterEnabled = ( ) = > {
if ( solhintEnabled ) {
setSolhintEnabled ( false ) ;
props . analysisModule . solhintEnabled = false
if ( basicEnabled ) {
setSelectedTab ( "remix" ) ;
setSelectedTab ( "remix" )
}
props . event . trigger ( "staticAnalysisWarning" , [ - 1 ] ) ;
props . event . trigger ( "staticAnalysisWarning" , [ - 1 ] )
} else {
setSolhintEnabled ( true ) ;
props . event . trigger ( "staticAnalysisWarning" , [ - 1 ] ) ;
setSolhintEnabled ( true )
props . analysisModule . solhintEnabled = true
props . event . trigger ( "staticAnalysisWarning" , [ - 1 ] )
}
} ;
@ -623,11 +640,70 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
{ hint . formattedMessage }
< / span >
< br / >
< span > { ` ${ hint . column } : ${ hint . line } ` } < / span >
< CustomTooltip
placement = "right"
tooltipId = "errorTooltip"
tooltipText = { ` Position in ${ state . file } ` }
tooltipClasses = "text-nowrap"
>
< span > { ` Pos: ${ hint . column } : ${ hint . line } ` } < / span >
< / CustomTooltip >
< / div >
< / div >
) )
: hintErrors . map ( ( hint , index ) = > (
: ! hideWarnings && ! showLibsWarning && ! basicEnabled && solhintEnabled ? hints . map ( ( hint , index ) = > (
< div
key = { index }
className = { ` ${
hint . type === "warning"
? "alert alert-warning"
: "alert alert-danger"
} ` }
style = { {
cursor : "pointer" ,
overflow : "hidden" ,
textOverflow : "ellipsis" ,
} }
onClick = { async ( ) = > {
await props . analysisModule . call (
"editor" ,
"discardHighlight"
) ;
await props . analysisModule . call (
"editor" ,
"highlight" ,
{
end : {
line : hint.line ,
column : hint.column + 1 ,
} ,
start : {
line : hint.line ,
column : hint.column ,
} ,
} ,
state . file ,
"" ,
{ focus : true }
) ;
} }
>
< div >
< span className = "text-wrap" >
{ hint . formattedMessage }
< / span >
< br / >
< CustomTooltip
placement = "right"
tooltipId = "errorTooltip"
tooltipText = { ` Position in ${ state . file } ` }
tooltipClasses = "text-nowrap"
>
< span > { ` Pos: ${ hint . column } : ${ hint . line } ` } < / span >
< / CustomTooltip >
< / div >
< / div >
) ) : hintErrors . map ( ( hint , index ) = > (
< div
key = { index }
className = "alert alert-danger"
@ -671,7 +747,14 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
{ hint . formattedMessage }
< / span >
< br / >
< span > { ` ${ hint . column } : ${ hint . line } ` } < / span >
< CustomTooltip
placement = "right"
tooltipId = "errorTooltip"
tooltipText = { ` Position in ${ state . file } ` }
tooltipClasses = "text-nowrap"
>
< span > { ` Pos: ${ hint . column } : ${ hint . line } ` } < / span >
< / CustomTooltip >
< / div >
< / div >
) ) }
@ -733,7 +816,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
) ,
child : (
< >
{ Object . entries ( warningState ) . length > 0 ? (
{ ssaWarnings . length > 0 ? (
< div id = "staticanalysisresult" >
< div className = "mb-4 pt-2" >
< div >
@ -751,6 +834,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
message = { x . msg }
opt = { x . options }
warningErrors = { "" }
ssaState = { state }
editor = { props . analysisModule }
/ >
< / div >
@ -767,11 +851,29 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
message = { x . msg }
opt = { x . options }
warningErrors = { "" }
ssaState = { state }
editor = { props . analysisModule }
/ >
< / div >
) )
: null }
: ! hideWarnings && ! showLibsWarning && basicEnabled
? ssaWarnings . filter ( ( x ) = > ! x . options . isLibrary && x . hasWarning )
. map ( ( x , i ) = > (
< div
data - id = { ` staticAnalysisModule ${ x . warningModuleName } ${ i } ` }
id = { ` staticAnalysisModule ${ x . warningModuleName } ${ i } ` }
key = { i }
>
< ErrorRenderer
name = { ` staticAnalysisModule ${ x . warningModuleName } ${ i } ` }
message = { x . msg }
opt = { x . options }
warningErrors = { "" }
ssaState = { state }
editor = { props . analysisModule }
/ >
< / div >
) ) : null }
< / div >
< / div >
< / div >
@ -838,6 +940,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
name = { ` staticAnalysisModule ${ warning . warningModuleName } ${ index } ` }
message = { warning . msg }
opt = { warning . options }
ssaState = { state }
warningErrors = { "" }
editor = { props . analysisModule }
/ >
@ -854,6 +957,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
message = { warning . msg }
opt = { warning . options }
warningErrors = { "" }
ssaState = { state }
editor = { props . analysisModule }
/ >
< / div >
@ -870,6 +974,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
name = { ` staticAnalysisModule ${ warning . warningModuleName } ${ index } ` }
message = { warning . msg }
opt = { warning . options }
ssaState = { state }
warningErrors = { "" }
editor = { props . analysisModule }
/ >
@ -919,7 +1024,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
. map ( ( value : any ) = > {
return value . map ( ( x ) = > {
return x . _index . toString ( ) ;
} )
} ) ;
} )
. flat ( )
. every ( ( el ) = > categoryIndex . includes ( el ) )
@ -1007,7 +1112,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
buttonText = { ` Analyze ${ state . file } ` }
title = { ` ${ runButtonTitle } ` }
classList = "btn btn-sm btn-primary btn-block"
onClick = { async ( ) = >
onClick = { async ( ) = > {
await run (
state . data ,
state . source ,
@ -1035,7 +1140,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
solhintEnabled ,
basicEnabled
)
}
} }
disabled = {
state . data === null ||
! isSupportedVersion ||
@ -1043,10 +1148,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}
/ >
) }
{ state &&
state . data !== null &&
state . source !== null &&
state . file . length > 0 ? (
{ ssaWarnings . length > 0 || hints . length > 0 ? (
< div className = "d-flex border-top flex-column" >
{ slitherWarnings . length > 0 ||
hints . length > 0 ||
@ -1070,7 +1172,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
< / div >
) : null }
< div
className = "border-top mt-2 pt-2 mb-2 "
className = "border-top mt-2 pt-2 mb-3 "
id = "staticanalysisresult"
>
< RemixUiCheckbox
@ -1089,7 +1191,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
name = "hideWarnings"
inputType = "checkbox"
checked = { hideWarnings }
label = "Hide warnings "
label = "Show errors only "
onClick = { handleHideWarnings }
onChange = { ( ) = > { } }
/ >
@ -1101,7 +1203,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
setSelectedTab ( tabKey ) ;
} }
>
< Nav variant = "tabs" className = "px-1" >
< Nav variant = "tabs" >
{ checkBasicStatus ( ) ? (
< Nav.Item >
< Nav.Link
@ -1113,7 +1215,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
< / Nav.Item >
) : null }
{ solhintEnabled ? (
< Nav.Item className = "text-decoration-none font-weight-bold px-2" >
< Nav.Item >
< Nav.Link
className = "text-decoration-none font-weight-bold px-2"
eventKey = { tabKeys [ 0 ] . tabKey }
@ -1123,7 +1225,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
< / Nav.Item >
) : null }
{ slitherEnabled && showSlither ? (
< Nav.Item className = "text-decoration-none font-weight-bold px-2" >
< Nav.Item >
< Nav.Link
className = "text-decoration-none font-weight-bold px-2"
eventKey = { tabKeys [ 2 ] . tabKey }
@ -1136,13 +1238,13 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
< Tab.Content >
< Tab.Pane eventKey = { tabKeys [ 1 ] . tabKey } >
{ tabKeys [ 1 ] . child }
{ basicEnabled ? tabKeys [ 1 ] . child : null }
< / Tab.Pane >
< Tab.Pane eventKey = { tabKeys [ 0 ] . tabKey } >
{ tabKeys [ 0 ] . child }
{ solhintEnabled ? tabKeys [ 0 ] . child : null }
< / Tab.Pane >
< Tab.Pane eventKey = { tabKeys [ 2 ] . tabKey } >
{ tabKeys [ 2 ] . child }
{ slitherEnabled && showSlither ? tabKeys [ 2 ] . child : null }
< / Tab.Pane >
< / Tab.Content >
< / TabContainer >
@ -1151,7 +1253,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
< / div >
< / div >
< / div >
) ;
} ;
)
}
export default RemixUiStaticAnalyser ;