comments added

pull/825/head
aniket-engg 4 years ago committed by Aniket
parent be714b7cfb
commit b3205690ee
  1. 3
      libs/remix-analyzer/src/solidity-analyzer/modules/similarVariableNames.ts

@ -46,10 +46,13 @@ export default class similarVariableNames implements AnalyzerModule {
} }
const vars: string[] = this.getFunctionVariables(contract, func).map(getDeclaredVariableName) const vars: string[] = this.getFunctionVariables(contract, func).map(getDeclaredVariableName)
this.findSimilarVarNames(vars).map((sim) => { this.findSimilarVarNames(vars).map((sim) => {
// check if function is implemented
if(func.node.implemented) { if(func.node.implemented) {
const astWalker = new AstWalker() const astWalker = new AstWalker()
const functionBody: any = func.node.body const functionBody: any = func.node.body
// Walk through all statements of function
astWalker.walk(functionBody, (node) => { 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.name === sim.var1 || node.name === sim.var2)) {
warnings.push({ warnings.push({
warning: `${funcName} : Variables have very similar names "${sim.var1}" and "${sim.var2}". ${hasModifiersComments} ${multipleContractsWithSameNameComments}`, warning: `${funcName} : Variables have very similar names "${sim.var1}" and "${sim.var2}". ${hasModifiersComments} ${multipleContractsWithSameNameComments}`,

Loading…
Cancel
Save