check variable declaration too

pull/825/head
aniket-engg 4 years ago committed by Aniket
parent a3358c383f
commit 94c834cb53
  1. 3
      libs/remix-analyzer/src/solidity-analyzer/modules/similarVariableNames.ts
  2. 2
      libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts
  3. 4
      libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts

@ -53,7 +53,8 @@ export default class similarVariableNames implements AnalyzerModule {
// Walk through all statements of function
astWalker.walk(functionBody, (node) => {
// check if these is an identifier node which is one of the tracked similar variables
if (node.nodeType === "Identifier" && (node.name === sim.var1 || node.name === sim.var2)) {
if ((node.nodeType === 'Identifier' || node.nodeType === 'VariableDeclaration')
&& (node.name === sim.var1 || node.name === sim.var2)) {
warnings.push({
warning: `${funcName} : Variables have very similar names "${sim.var1}" and "${sim.var2}". ${hasModifiersComments} ${multipleContractsWithSameNameComments}`,
location: node['src']

@ -283,7 +283,7 @@ test('Integration test similarVariableNames module', function (t: test.Test) {
'inheritance.sol': 0,
'modifier1.sol': 0,
'modifier2.sol': 0,
'notReentrant.sol': 3,
'notReentrant.sol': 4,
'structReentrant.sol': 0,
'thisLocal.sol': 0,
'globals.sol': 0,

@ -279,13 +279,13 @@ test('Integration test similarVariableNames module', function (t: test.Test) {
'KingOfTheEtherThrone.sol': 0,
'assembly.sol': 0,
'ballot.sol': 7,
'ballot_reentrant.sol': 24,
'ballot_reentrant.sol': 40,
'ballot_withoutWarnings.sol': 0,
'cross_contract.sol': 0,
'inheritance.sol': 0,
'modifier1.sol': 0,
'modifier2.sol': 0,
'notReentrant.sol': 3,
'notReentrant.sol': 4,
'structReentrant.sol': 0,
'thisLocal.sol': 0,
'globals.sol': 0,

Loading…
Cancel
Save