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
bed67f2b
Commit
bed67f2b
authored
Mar 12, 2017
by
Michael Fröwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Categories for static analysis modules
parent
a6ece05c
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
4 deletions
+82
-4
categories.js
src/app/staticanalysis/modules/categories.js
+4
-0
gasCosts.js
src/app/staticanalysis/modules/gasCosts.js
+2
-0
txOrigin.js
src/app/staticanalysis/modules/txOrigin.js
+2
-0
staticAnalysisView.js
src/app/staticanalysis/staticAnalysisView.js
+35
-3
utils.js
src/app/utils.js
+12
-1
index.js
test/index.js
+1
-0
util-test.js
test/util-test.js
+26
-0
No files found.
src/app/staticanalysis/modules/categories.js
0 → 100644
View file @
bed67f2b
module
.
exports
=
{
SECURITY
:
{
displayName
:
'Security'
,
id
:
'SEC'
},
GAS
:
{
displayName
:
'Gas & Economy'
,
id
:
'GAS'
}
}
src/app/staticanalysis/modules/gasCosts.js
View file @
bed67f2b
var
name
=
'gas costs'
var
name
=
'gas costs'
var
desc
=
'Warn if the gas requiremets of functions are too high.'
var
desc
=
'Warn if the gas requiremets of functions are too high.'
var
categories
=
require
(
'./categories'
)
function
gasCosts
()
{
function
gasCosts
()
{
}
}
...
@@ -46,5 +47,6 @@ gasCosts.prototype.report = function (compilationResults) {
...
@@ -46,5 +47,6 @@ gasCosts.prototype.report = function (compilationResults) {
module
.
exports
=
{
module
.
exports
=
{
name
:
name
,
name
:
name
,
description
:
desc
,
description
:
desc
,
category
:
categories
.
GAS
,
Module
:
gasCosts
Module
:
gasCosts
}
}
src/app/staticanalysis/modules/txOrigin.js
View file @
bed67f2b
var
name
=
'tx origin'
var
name
=
'tx origin'
var
desc
=
'warn if tx.origin is used'
var
desc
=
'warn if tx.origin is used'
var
categories
=
require
(
'./categories'
)
function
txOrigin
()
{
function
txOrigin
()
{
this
.
txOriginNodes
=
[]
this
.
txOriginNodes
=
[]
...
@@ -29,5 +30,6 @@ txOrigin.prototype.report = function () {
...
@@ -29,5 +30,6 @@ txOrigin.prototype.report = function () {
module
.
exports
=
{
module
.
exports
=
{
name
:
name
,
name
:
name
,
description
:
desc
,
description
:
desc
,
category
:
categories
.
SECURITY
,
Module
:
txOrigin
Module
:
txOrigin
}
}
src/app/staticanalysis/staticAnalysisView.js
View file @
bed67f2b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
var
StaticAnalysisRunner
=
require
(
'./staticAnalysisRunner.js'
)
var
StaticAnalysisRunner
=
require
(
'./staticAnalysisRunner.js'
)
var
yo
=
require
(
'yo-yo'
)
var
yo
=
require
(
'yo-yo'
)
var
$
=
require
(
'jquery'
)
var
$
=
require
(
'jquery'
)
var
utils
=
require
(
'../utils'
)
function
staticAnalysisView
(
appAPI
,
compilerEvent
)
{
function
staticAnalysisView
(
appAPI
,
compilerEvent
)
{
this
.
view
=
null
this
.
view
=
null
...
@@ -26,7 +27,7 @@ staticAnalysisView.prototype.render = function () {
...
@@ -26,7 +27,7 @@ staticAnalysisView.prototype.render = function () {
var
self
=
this
var
self
=
this
var
view
=
yo
`<div>
var
view
=
yo
`<div>
<strong>Static Analysis</strong>
<strong>Static Analysis</strong>
<label for="autorunstaticanalysis"><input id="autorunstaticanalysis" type="checkbox" checked="true">Auto run</label>
<label for="autorunstaticanalysis"><input id="autorunstaticanalysis" type="checkbox"
style="vertical-align:bottom"
checked="true">Auto run</label>
<div id="staticanalysismodules">
<div id="staticanalysismodules">
${
this
.
modulesView
}
${
this
.
modulesView
}
</div>
</div>
...
@@ -94,7 +95,38 @@ staticAnalysisView.prototype.run = function () {
...
@@ -94,7 +95,38 @@ staticAnalysisView.prototype.run = function () {
module
.
exports
=
staticAnalysisView
module
.
exports
=
staticAnalysisView
function
renderModules
(
modules
)
{
function
renderModules
(
modules
)
{
return
modules
.
map
(
function
(
item
,
i
)
{
var
groupedModules
=
utils
.
groupBy
(
preProcessModules
(
modules
),
'categoryId'
)
return
yo
`<label><input id="staticanalysismodule
${
i
}
" type="checkbox" name="staticanalysismodule" index=
${
i
}
checked="true">
${
item
.
name
}
(
${
item
.
description
}
)</label>`
return
Object
.
keys
(
groupedModules
).
map
((
categoryId
,
i
)
=>
{
var
category
=
groupedModules
[
categoryId
]
var
entriesDom
=
category
.
map
((
item
,
i
)
=>
{
return
yo
`<label>
<input id="staticanalysismodule_
${
categoryId
}
_
${
i
}
"
type="checkbox"
name="staticanalysismodule"
index=
${
item
.
_index
}
checked="true" style="vertical-align:bottom">
${
item
.
name
}
(
${
item
.
description
}
)
</label>`
})
return
yo
`<div>
<label>
<b>
${
category
[
0
].
categoryDisplayName
}
</b> (
<input id="staticanalysismodule_
${
categoryId
}
"
type="checkbox"
checked="true"
style="vertical-align:bottom; margin-left:0"
onchange=
${
function
()
{
$
(
'[id^='
+
this
.
id
+
']'
).
prop
(
'checked'
,
this
.
checked
)
}
}/> all/none)
</label>
${
entriesDom
}
</div>`
})
}
function
preProcessModules
(
arr
)
{
return
arr
.
map
((
item
,
i
)
=>
{
item
[
'_index'
]
=
i
item
.
categoryDisplayName
=
item
.
category
.
displayName
item
.
categoryId
=
item
.
category
.
id
return
item
})
})
}
}
src/app/utils.js
View file @
bed67f2b
...
@@ -4,6 +4,17 @@ function errortype (message) {
...
@@ -4,6 +4,17 @@ function errortype (message) {
return
message
.
match
(
/^
(
.*:
[
0-9
]
*:
[
0-9
]
*
)?
Warning: /
)
?
'warning'
:
'error'
return
message
.
match
(
/^
(
.*:
[
0-9
]
*:
[
0-9
]
*
)?
Warning: /
)
?
'warning'
:
'error'
}
}
function
groupBy
(
arr
,
key
)
{
return
arr
.
reduce
((
sum
,
item
)
=>
{
const
groupByVal
=
item
[
key
]
var
groupedItems
=
sum
[
groupByVal
]
||
[]
groupedItems
.
push
(
item
)
sum
[
groupByVal
]
=
groupedItems
return
sum
},
{})
}
module
.
exports
=
{
module
.
exports
=
{
errortype
:
errortype
errortype
:
errortype
,
groupBy
:
groupBy
}
}
test/index.js
View file @
bed67f2b
...
@@ -3,3 +3,4 @@
...
@@ -3,3 +3,4 @@
require
(
'./compiler-test'
)
require
(
'./compiler-test'
)
require
(
'./gist-handler-test'
)
require
(
'./gist-handler-test'
)
require
(
'./query-params-test'
)
require
(
'./query-params-test'
)
require
(
'./util-test'
)
test/util-test.js
0 → 100644
View file @
bed67f2b
var
test
=
require
(
'tape'
)
var
utils
=
require
(
'../babelify-src/app/utils'
)
test
(
'util.groupBy on valid input'
,
function
(
t
)
{
t
.
plan
(
1
)
var
result
=
utils
.
groupBy
([
{
category
:
'GAS'
,
name
:
'a'
},
{
category
:
'SEC'
,
name
:
'b'
},
{
category
:
'GAS'
,
name
:
'c'
}
],
'category'
)
var
expectedResult
=
{
'GAS'
:
[
{
category
:
'GAS'
,
name
:
'a'
},
{
category
:
'GAS'
,
name
:
'c'
}
],
'SEC'
:
[
{
category
:
'SEC'
,
name
:
'b'
}
]
}
t
.
deepEqual
(
result
,
expectedResult
)
})
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