Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
bee567ac
Commit
bee567ac
authored
Jun 23, 2021
by
aniket-engg
Committed by
Aniket
Jul 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
intermediate commit
parent
27950219
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
24 deletions
+80
-24
remix-ui-static-analyser.tsx
...x-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx
+80
-24
No files found.
libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx
View file @
bee567ac
...
@@ -110,12 +110,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
...
@@ -110,12 +110,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
if
(
lastCompilationResult
&&
categoryIndex
.
length
>
0
)
{
if
(
lastCompilationResult
&&
categoryIndex
.
length
>
0
)
{
let
warningCount
=
0
let
warningCount
=
0
const
warningMessage
=
[]
const
warningMessage
=
[]
if
(
slitherEnabled
)
{
const
warningErrors
=
[]
props
.
analysisModule
.
call
(
'solidity-logic'
,
'getCompilerState'
).
then
((
compilerState
)
=>
{
const
{
currentVersion
,
optimize
,
evmVersion
}
=
compilerState
/******************** Remix Analyzer ********************/
props
.
analysisModule
.
call
(
'slither'
,
'analyse'
,
state
.
file
,
{
currentVersion
,
optimize
,
evmVersion
}).
then
(
console
.
log
)
})
}
runner
.
run
(
lastCompilationResult
,
categoryIndex
,
results
=>
{
runner
.
run
(
lastCompilationResult
,
categoryIndex
,
results
=>
{
results
.
map
((
result
)
=>
{
results
.
map
((
result
)
=>
{
let
moduleName
let
moduleName
...
@@ -126,7 +123,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
...
@@ -126,7 +123,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
}
}
})
})
})
})
const
warningErrors
=
[]
result
.
report
.
map
((
item
)
=>
{
result
.
report
.
map
((
item
)
=>
{
let
location
:
any
=
{}
let
location
:
any
=
{}
let
locationString
=
'not available'
let
locationString
=
'not available'
...
@@ -170,25 +166,85 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
...
@@ -170,25 +166,85 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
warningMessage
.
push
({
msg
,
options
,
hasWarning
:
true
,
warningModuleName
:
moduleName
})
warningMessage
.
push
({
msg
,
options
,
hasWarning
:
true
,
warningModuleName
:
moduleName
})
})
})
})
})
const
resultArray
=
[]
})
warningMessage
.
map
(
x
=>
{
resultArray
.
push
(
x
)
/******************** Slither Analyzer Start ********************/
})
function
groupBy
(
objectArray
,
property
)
{
if
(
slitherEnabled
)
{
return
objectArray
.
reduce
((
acc
,
obj
)
=>
{
props
.
analysisModule
.
call
(
'solidity-logic'
,
'getCompilerState'
).
then
((
compilerState
)
=>
{
const
key
=
obj
[
property
]
const
{
currentVersion
,
optimize
,
evmVersion
}
=
compilerState
if
(
!
acc
[
key
])
{
props
.
analysisModule
.
call
(
'slither'
,
'analyse'
,
state
.
file
,
{
currentVersion
,
optimize
,
evmVersion
}).
then
((
result
)
=>
{
acc
[
key
]
=
[]
console
.
log
(
'slither result'
)
if
(
result
.
status
)
{
const
report
=
result
.
data
report
.
map
((
item
)
=>
{
let
location
:
any
=
{}
let
locationString
=
'not available'
let
column
=
0
let
row
=
0
let
fileName
=
currentFile
if
(
item
.
sourceMap
&
item
.
sourceMap
.
length
)
{
location
=
{
start
:
item
.
sourceMap
[
0
].
source_mapping
.
start
,
length
:
item
.
sourceMap
[
0
].
source_mapping
.
length
}
location
=
props
.
analysisModule
.
_deps
.
offsetToLineColumnConverter
.
offsetToLineColumn
(
location
,
0
,
lastCompilationSource
.
sources
,
lastCompilationResult
.
sources
)
console
.
log
(
'location:'
,
location
)
row
=
location
.
start
.
line
column
=
location
.
start
.
column
locationString
=
row
+
1
+
':'
+
column
+
':'
fileName
=
Object
.
keys
(
lastCompilationResult
.
contracts
)[
0
]
}
warningCount
++
const
msg
=
message
(
item
.
title
,
item
.
description
,
item
.
more
,
fileName
,
locationString
)
const
options
=
{
type
:
'warning'
,
useSpan
:
true
,
errFile
:
fileName
,
fileName
,
errLine
:
row
,
errCol
:
column
,
item
:
item
,
name
:
item
.
title
,
locationString
,
more
:
item
.
more
,
location
:
location
}
warningErrors
.
push
(
options
)
warningMessage
.
push
({
msg
,
options
,
hasWarning
:
true
,
warningModuleName
:
item
.
title
})
})
}
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
},
{})
}
}
// Add object to list for given key's value
acc
[
key
].
push
(
obj
)
return
acc
},
{})
}
const
groupedCategory
=
groupBy
(
resultArray
,
'warningModuleName'
)
const
groupedCategory
=
groupBy
(
resultArray
,
'warningModuleName'
)
setWarningState
(
groupedCategory
)
setWarningState
(
groupedCategory
)
})
})
})
}
/******************** Slither Analyzer Finish ********************/
if
(
categoryIndex
.
length
>
0
)
{
if
(
categoryIndex
.
length
>
0
)
{
props
.
event
.
trigger
(
'staticAnaysisWarning'
,
[
warningCount
])
props
.
event
.
trigger
(
'staticAnaysisWarning'
,
[
warningCount
])
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment