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
369279cb
Commit
369279cb
authored
Apr 27, 2021
by
tizah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored static analysis to improve performance
parent
43ae28e4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
113 deletions
+16
-113
StaticAnalyserCheckedBox.tsx
...ic-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx
+0
-45
ErrorRenderer.tsx
libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx
+2
-1
staticAnalysisActions.ts
.../static-analyser/src/lib/actions/staticAnalysisActions.ts
+3
-13
staticAnalysisReducer.ts
...static-analyser/src/lib/reducers/staticAnalysisReducer.ts
+11
-54
remix-ui-static-analyser.tsx
...x-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx
+0
-0
No files found.
libs/remix-ui/static-analyser/src/lib/Checkbox/StaticAnalyserCheckedBox.tsx
deleted
100644 → 0
View file @
43ae28e4
import
React
from
'react'
//eslint-disable-line
interface
StaticAnalyserCheckBoxProps
{
onClick
?:
(
event
)
=>
void
onChange
?:
(
event
)
=>
void
label
?:
string
inputType
?:
string
name
?:
string
checked
?:
boolean
id
?:
string
itemName
?:
string
categoryId
?:
string
}
const
StaticAnalyserCheckedBox
=
({
id
,
label
,
onClick
,
inputType
,
name
,
checked
,
onChange
,
itemName
,
categoryId
}:
StaticAnalyserCheckBoxProps
)
=>
{
return
(
<
div
className=
"listenOnNetwork_2A0YE0 custom-control custom-checkbox"
style=
{
{
display
:
'flex'
,
alignItems
:
'center'
}
}
onClick=
{
onClick
}
>
<
input
id=
{
id
}
type=
{
inputType
}
onChange=
{
onChange
}
style=
{
{
verticalAlign
:
'bottom'
}
}
name=
{
name
}
className=
"custom-control-input"
checked=
{
checked
}
/>
<
label
className=
"form-check-label custom-control-label"
id=
{
`heading${categoryId}`
}
style=
{
{
paddingTop
:
'0.15rem'
}
}
>
{
name
?
<
div
className=
"font-weight-bold"
>
{
itemName
}
</
div
>
:
''
}
{
label
}
</
label
>
</
div
>
)
}
export
default
StaticAnalyserCheckedBox
libs/remix-ui/static-analyser/src/lib/ErrorRenderer.tsx
View file @
369279cb
import
React
,
{
useState
}
from
'react'
//eslint-disable-line
import
React
from
'react'
//eslint-disable-line
interface
ErrorRendererProps
{
message
:
any
;
...
...
@@ -32,6 +32,7 @@ const ErrorRenderer = ({ message, opt, editor }: ErrorRendererProps) => {
if
(
!
message
)
return
let
position
=
getPositionDetails
(
message
)
console
.
log
({
position
})
if
(
!
position
.
errFile
||
(
opt
.
errorType
&&
opt
.
errorType
===
position
.
errFile
))
{
// Updated error reported includes '-->' before file details
const
errorDetails
=
message
.
split
(
'-->'
)
...
...
libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts
View file @
369279cb
import
React
,
{
useState
}
from
'react'
//eslint-disable-line
import
React
from
'react'
//eslint-disable-line
export
const
compilation
=
(
analysisModule
,
state
,
run
)
=>
{
// const setCompilationResult = async (data, source, file) => {
// await setResult({ lastCompilationResult: data, lastCompilationSource: source, currentFile: file })
// }
export
const
compilation
=
(
analysisModule
,
dispatch
)
=>
{
if
(
analysisModule
)
{
analysisModule
.
on
(
'solidity'
,
'compilationFinished'
,
(
file
,
source
,
languageVersion
,
data
)
=>
{
if
(
languageVersion
.
indexOf
(
'soljson'
)
!==
0
)
return
setCompilationResult
(
data
,
source
,
file
)
if
(
state
.
categoryIndex
.
length
>
0
)
{
run
(
data
,
source
,
file
)
}
dispatch
({
type
:
'compilationFinished'
,
payload
:
{
file
,
source
,
languageVersion
,
data
}
})
}
)
}
}
export
const
setCompilationResult
=
async
(
data
,
source
,
file
)
=>
{
return
await
{
data
,
source
,
file
}
}
libs/remix-ui/static-analyser/src/lib/reducers/staticAnalysisReducer.ts
View file @
369279cb
import
remixLib
from
'@remix-project/remix-lib'
import
*
as
_
from
'lodash'
const
StaticAnalysisRunner
=
require
(
'@remix-project/remix-analyzer'
).
CodeAnalysis
const
utils
=
remixLib
.
util
const
runner
=
new
StaticAnalysisRunner
()
const
preProcessModules
=
(
arr
:
any
)
=>
{
return
arr
.
map
((
Item
,
i
)
=>
{
const
itemObj
=
new
Item
()
itemObj
.
_index
=
i
itemObj
.
categoryDisplayName
=
itemObj
.
category
.
displayName
itemObj
.
categoryId
=
itemObj
.
category
.
id
return
itemObj
})
}
const
groupedModules
=
utils
.
groupBy
(
preProcessModules
(
runner
.
modules
()),
'categoryId'
)
const
getIndex
=
(
modules
,
array
)
=>
{
Object
.
values
(
modules
).
map
((
value
:
{
_index
})
=>
{
if
(
Array
.
isArray
(
value
))
{
value
.
forEach
((
x
)
=>
{
array
.
push
(
x
.
_index
.
toString
())
})
}
else
{
array
.
push
(
value
.
_index
.
toString
())
}
})
}
const
groupedModuleIndex
=
(
modules
)
=>
{
const
indexOfCategory
=
[]
if
(
!
_
.
isEmpty
(
modules
))
{
getIndex
(
modules
,
indexOfCategory
)
}
return
indexOfCategory
export
const
initialState
=
{
file
:
null
,
source
:
null
,
languageVersion
:
null
,
data
:
null
}
export
const
initialState
=
{
categoryIndex
:
[]
}
export
const
analysisReducer
=
(
state
,
action
)
=>
{
switch
(
action
.
type
)
{
case
'initialize'
:
return
{
...
state
,
categoryIndex
:
groupedModuleIndex
(
groupedModules
)
}
case
'uncheck'
:
case
'compilationFinished'
:
return
{
...
state
,
categoryIndex
:
state
.
categoryIndex
.
filter
((
el
)
=>
{
return
!
action
.
payload
.
includes
(
el
)
})
file
:
action
.
payload
.
file
,
source
:
action
.
payload
.
source
,
languageVersion
:
action
.
payload
.
languageVersion
,
data
:
action
.
payload
.
data
}
case
'check'
:
return
{
...
state
,
categoryIndex
:
_
.
uniq
([...
state
.
categoryIndex
,
...
action
.
payload
])
}
case
'uncheckSingle'
:
return
{
...
state
,
categoryIndex
:
state
.
categoryIndex
.
filter
(
val
=>
val
!==
action
.
payload
)
}
case
'checkSingle'
:
return
{
...
state
,
categoryIndex
:
_
.
uniq
([...
state
.
categoryIndex
,
action
.
payload
])
}
default
:
return
{
...
state
,
categoryIndex
:
groupedModuleIndex
(
groupedModules
)
}
return
initialState
}
}
libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx
View file @
369279cb
This diff is collapsed.
Click to expand it.
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