|
|
@ -44,7 +44,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
results = [] |
|
|
|
results = [] |
|
|
|
for contract in self.contracts: |
|
|
|
for contract in self.contracts: |
|
|
|
|
|
|
|
|
|
|
|
if self.is_cap_words(contract.name) is False: |
|
|
|
if not self.is_cap_words(contract.name): |
|
|
|
info = "Contract '{}' is not in CapWords".format(contract.name) |
|
|
|
info = "Contract '{}' is not in CapWords".format(contract.name) |
|
|
|
self.log(info) |
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
|
|
@ -57,7 +57,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
if struct.contract != contract: |
|
|
|
if struct.contract != contract: |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if self.is_cap_words(struct.name) is False: |
|
|
|
if not self.is_cap_words(struct.name): |
|
|
|
info = "Struct '{}' is not in CapWords, Contract: '{}' ".format(struct.name, contract.name) |
|
|
|
info = "Struct '{}' is not in CapWords, Contract: '{}' ".format(struct.name, contract.name) |
|
|
|
self.log(info) |
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
|
|
@ -71,7 +71,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
if event.contract != contract: |
|
|
|
if event.contract != contract: |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if self.is_cap_words(event.name) is False: |
|
|
|
if not self.is_cap_words(event.name): |
|
|
|
info = "Event '{}' is not in CapWords, Contract: '{}' ".format(event.name, contract.name) |
|
|
|
info = "Event '{}' is not in CapWords, Contract: '{}' ".format(event.name, contract.name) |
|
|
|
self.log(info) |
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
|
|
@ -85,7 +85,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
if func.contract != contract: |
|
|
|
if func.contract != contract: |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if self.is_mixed_case(func.name) is False: |
|
|
|
if not self.is_mixed_case(func.name): |
|
|
|
info = "Function '{}' is not in mixedCase, Contract: '{}' ".format(func.name, contract.name) |
|
|
|
info = "Function '{}' is not in mixedCase, Contract: '{}' ".format(func.name, contract.name) |
|
|
|
self.log(info) |
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
|
|
@ -97,10 +97,10 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
|
|
|
|
|
|
|
for argument in func.parameters: |
|
|
|
for argument in func.parameters: |
|
|
|
if argument in func.variables_read_or_written: |
|
|
|
if argument in func.variables_read_or_written: |
|
|
|
incorrect_naming = self.is_mixed_case(argument.name) is False |
|
|
|
correct_naming = self.is_mixed_case(argument.name) |
|
|
|
else: |
|
|
|
else: |
|
|
|
incorrect_naming = self.is_mixed_case_with_underscore(argument.name) is False |
|
|
|
correct_naming = self.is_mixed_case_with_underscore(argument.name) |
|
|
|
if incorrect_naming: |
|
|
|
if not correct_naming: |
|
|
|
info = "Parameter '{}' is not in mixedCase, Contract: '{}', Function: '{}'' " \ |
|
|
|
info = "Parameter '{}' is not in mixedCase, Contract: '{}', Function: '{}'' " \ |
|
|
|
.format(argument.name, argument.name, contract.name) |
|
|
|
.format(argument.name, argument.name, contract.name) |
|
|
|
self.log(info) |
|
|
|
self.log(info) |
|
|
@ -117,7 +117,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if self.should_avoid_name(var.name): |
|
|
|
if self.should_avoid_name(var.name): |
|
|
|
if self.is_upper_case_with_underscores(var.name) is False: |
|
|
|
if not self.is_upper_case_with_underscores(var.name): |
|
|
|
info = "Variable '{}' l, O, I should not be used, Contract: '{}' " \ |
|
|
|
info = "Variable '{}' l, O, I should not be used, Contract: '{}' " \ |
|
|
|
.format(var.name, contract.name) |
|
|
|
.format(var.name, contract.name) |
|
|
|
self.log(info) |
|
|
|
self.log(info) |
|
|
@ -133,7 +133,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
if var.name in ['symbol', 'name', 'decimals']: |
|
|
|
if var.name in ['symbol', 'name', 'decimals']: |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if self.is_upper_case_with_underscores(var.name) is False: |
|
|
|
if not self.is_upper_case_with_underscores(var.name): |
|
|
|
info = "Constant '{}' is not in UPPER_CASE_WITH_UNDERSCORES, Contract: '{}' " \ |
|
|
|
info = "Constant '{}' is not in UPPER_CASE_WITH_UNDERSCORES, Contract: '{}' " \ |
|
|
|
.format(var.name, contract.name) |
|
|
|
.format(var.name, contract.name) |
|
|
|
self.log(info) |
|
|
|
self.log(info) |
|
|
@ -145,10 +145,10 @@ class NamingConvention(AbstractDetector): |
|
|
|
'sourceMapping': var.source_mapping}) |
|
|
|
'sourceMapping': var.source_mapping}) |
|
|
|
else: |
|
|
|
else: |
|
|
|
if var.visibility == 'private': |
|
|
|
if var.visibility == 'private': |
|
|
|
incorrect_naming = self.is_mixed_case_with_underscore(var.name) is False |
|
|
|
correct_naming = self.is_mixed_case_with_underscore(var.name) |
|
|
|
else: |
|
|
|
else: |
|
|
|
incorrect_naming = self.is_mixed_case(var.name) is False |
|
|
|
correct_naming = self.is_mixed_case(var.name) |
|
|
|
if incorrect_naming: |
|
|
|
if not correct_naming: |
|
|
|
info = "Variable '{}' is not in mixedCase, Contract: '{}' ".format(var.name, contract.name) |
|
|
|
info = "Variable '{}' is not in mixedCase, Contract: '{}' ".format(var.name, contract.name) |
|
|
|
self.log(info) |
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
|
|
@ -162,7 +162,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
if enum.contract != contract: |
|
|
|
if enum.contract != contract: |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if self.is_cap_words(enum.name) is False: |
|
|
|
if not self.is_cap_words(enum.name): |
|
|
|
info = "Enum '{}' is not in CapWords, Contract: '{}' ".format(enum.name, contract.name) |
|
|
|
info = "Enum '{}' is not in CapWords, Contract: '{}' ".format(enum.name, contract.name) |
|
|
|
self.log(info) |
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
|
|
@ -176,7 +176,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
if modifier.contract != contract: |
|
|
|
if modifier.contract != contract: |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if self.is_mixed_case(modifier.name) is False: |
|
|
|
if not self.is_mixed_case(modifier.name): |
|
|
|
info = "Modifier '{}' is not in mixedCase, Contract: '{}' ".format(modifier.name, contract.name) |
|
|
|
info = "Modifier '{}' is not in mixedCase, Contract: '{}' ".format(modifier.name, contract.name) |
|
|
|
self.log(info) |
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
|
|
|