Commit 5594cdea authored by aniket-engg's avatar aniket-engg Committed by Aniket

guard conditions with location

parent 075051e9
...@@ -15,12 +15,12 @@ export default class guardConditions implements AnalyzerModule { ...@@ -15,12 +15,12 @@ export default class guardConditions implements AnalyzerModule {
} }
report (compilationResults: CompilationResult): ReportObj[] { report (compilationResults: CompilationResult): ReportObj[] {
if (this.guards.length > 0) { return this.guards.map((node) => {
return [{ return {
warning: 'Use assert(x) if you never ever want x to be false, not in any circumstance (apart from a bug in your code). Use require(x) if x can be false, due to e.g. invalid input or a failing external component.', warning: `Use 'assert(x)' if you never ever want x to be false, not in any circumstance (apart from a bug in your code). Use 'require(x)' if x can be false, due to e.g. invalid input or a failing external component.`,
location: node.src,
more: 'http://solidity.readthedocs.io/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions' more: 'http://solidity.readthedocs.io/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions'
}]
} }
return [] })
} }
} }
...@@ -486,7 +486,7 @@ test('Integration test guardConditions module', function (t: test.Test) { ...@@ -486,7 +486,7 @@ test('Integration test guardConditions module', function (t: test.Test) {
const module: any = modules.guardConditions const module: any = modules.guardConditions
const lengthCheck: Record<string, number> = { const lengthCheck: Record<string, number> = {
'KingOfTheEtherThrone.sol': 0, 'KingOfTheEtherThrone.sol': 0,
'assembly.sol': 1, 'assembly.sol': 2,
'ballot.sol': 0, 'ballot.sol': 0,
'ballot_reentrant.sol': 0, 'ballot_reentrant.sol': 0,
'ballot_withoutWarnings.sol': 0, 'ballot_withoutWarnings.sol': 0,
......
...@@ -448,7 +448,7 @@ test('Integration test guardConditions module', function (t: test.Test) { ...@@ -448,7 +448,7 @@ test('Integration test guardConditions module', function (t: test.Test) {
const module: any = modules.guardConditions const module: any = modules.guardConditions
const lengthCheck: Record<string, number> = { const lengthCheck: Record<string, number> = {
'KingOfTheEtherThrone.sol': 0, 'KingOfTheEtherThrone.sol': 0,
'assembly.sol': 1, 'assembly.sol': 2,
'ballot.sol': 0, 'ballot.sol': 0,
'ballot_reentrant.sol': 0, 'ballot_reentrant.sol': 0,
'ballot_withoutWarnings.sol': 0, 'ballot_withoutWarnings.sol': 0,
......
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