Commit b3205690 authored by aniket-engg's avatar aniket-engg Committed by Aniket

comments added

parent be714b7c
...@@ -46,10 +46,13 @@ export default class similarVariableNames implements AnalyzerModule { ...@@ -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}`,
......
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