guard conditions with location

pull/7/head
aniket-engg 5 years ago committed by Aniket
parent 075051e9c6
commit 5594cdea38
  1. 12
      remix-analyzer/src/solidity-analyzer/modules/guardConditions.ts
  2. 2
      remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts
  3. 2
      remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts

@ -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) {
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) {
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,

Loading…
Cancel
Save