Commit f96ff72a authored by chriseth's avatar chriseth Committed by GitHub

Merge pull request #316 from ethereum/improveStaticAnalysis2

static analysis: Highlight static analysis tab if warning and trigger a run for each compilation
parents 3199cf11 cc78c664
......@@ -178,7 +178,7 @@ body {
#header #options li {
float: left;
padding: 0.5em 0.6em;
padding: 0.3em 0.6em;
font-size: 1em;
cursor: pointer;
background-color: transparent;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -43,7 +43,7 @@ function Debugger (id, editor, compiler, executionContextEvent, switchToFile, of
if (self.lastCompilationResult) {
this.debugger.sourceLocationTracker.getSourceLocation(address, index, self.lastCompilationResult.data.contracts, function (error, rawLocation) {
if (!error) {
var lineColumnPos = self.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self.editor, self.lastCompilationResult)
var lineColumnPos = self.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self.editor, self.lastCompilationResult.data)
self.highlight(lineColumnPos, rawLocation)
} else {
self.removeCurrentMarker()
......
......@@ -20,7 +20,8 @@ txOrigin.prototype.report = function (node) {
var report = []
this.txOriginNode.map(function (item, i) {
report.push({
warning: 'use of tx.origin: "tx.origin" is useful only in very exceptional cases.\nIf you use it for authentication, you usually want to replace it by "msg.sender", because otherwise any contract you call can act on your behalf.',
warning: `use of tx.origin: "tx.origin" is useful only in very exceptional cases.\n
If you use it for authentication, you usually want to replace it by "msg.sender", because otherwise any contract you call can act on your behalf.`,
location: item.src
})
})
......
......@@ -17,6 +17,9 @@ function staticAnalysisView (compilerEvent, renderer, editor, offsetToColumnConv
$('#staticanalysisresult').empty()
if (success) {
self.lastCompilationResult = data
if (self.view.querySelector('#autorunstaticanalysis').checked) {
self.run()
}
}
})
}
......@@ -25,7 +28,7 @@ staticAnalysisView.prototype.render = function () {
var self = this
var view = yo`<div>
<strong>Static Analysis</strong>
<div>Select analyser to run against current compiled contracts</div>
<div>Select analyser to run against current compiled contracts <label><input id="autorunstaticanalysis" type="checkbox" checked="true">Auto run Static Analysis</label></div>
${this.modulesView}
<div>
<button onclick=${function () { self.run() }} >Run</button>
......@@ -77,16 +80,22 @@ staticAnalysisView.prototype.run = function () {
self.renderer.error(location + ' ' + item.warning, warningContainer, false, 'warning')
})
})
if (warningContainer.html() === '') {
$('#header #menu .staticanalysisView').css('color', '')
warningContainer.html('No warning to report')
} else {
$('#header #menu .staticanalysisView').css('color', '#FF8B8B')
}
})
} else {
warningContainer.html('No compiled AST available')
}
}
module.exports = staticAnalysisView
function renderModules (modules) {
return modules.map(function (item, i) {
return yo`<div><input type="checkbox" name="staticanalysismodule" checked='true' index=${i} >${item.name} (${item.description})</div>`
return yo`<label><input id="staticanalysismodule${i}" type="checkbox" name="staticanalysismodule" index=${i} checked="true">${item.name} (${item.description})</label>`
})
}
module.exports = staticAnalysisView
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment