|
|
|
@ -44,7 +44,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
results = [] |
|
|
|
|
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) |
|
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
@ -57,7 +57,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
if struct.contract != contract: |
|
|
|
|
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) |
|
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
@ -71,7 +71,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
if event.contract != contract: |
|
|
|
|
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) |
|
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
@ -85,7 +85,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
if func.contract != contract: |
|
|
|
|
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) |
|
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
@ -97,10 +97,10 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
|
|
|
|
|
for argument in func.parameters: |
|
|
|
|
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: |
|
|
|
|
incorrect_naming = self.is_mixed_case_with_underscore(argument.name) is False |
|
|
|
|
if incorrect_naming: |
|
|
|
|
correct_naming = self.is_mixed_case_with_underscore(argument.name) |
|
|
|
|
if not correct_naming: |
|
|
|
|
info = "Parameter '{}' is not in mixedCase, Contract: '{}', Function: '{}'' " \ |
|
|
|
|
.format(argument.name, argument.name, contract.name) |
|
|
|
|
self.log(info) |
|
|
|
@ -117,7 +117,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
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: '{}' " \ |
|
|
|
|
.format(var.name, contract.name) |
|
|
|
|
self.log(info) |
|
|
|
@ -133,7 +133,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
if var.name in ['symbol', 'name', 'decimals']: |
|
|
|
|
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: '{}' " \ |
|
|
|
|
.format(var.name, contract.name) |
|
|
|
|
self.log(info) |
|
|
|
@ -145,10 +145,10 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
'sourceMapping': var.source_mapping}) |
|
|
|
|
else: |
|
|
|
|
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: |
|
|
|
|
incorrect_naming = self.is_mixed_case(var.name) is False |
|
|
|
|
if incorrect_naming: |
|
|
|
|
correct_naming = self.is_mixed_case(var.name) |
|
|
|
|
if not correct_naming: |
|
|
|
|
info = "Variable '{}' is not in mixedCase, Contract: '{}' ".format(var.name, contract.name) |
|
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
@ -162,7 +162,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
if enum.contract != contract: |
|
|
|
|
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) |
|
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
@ -176,7 +176,7 @@ class NamingConvention(AbstractDetector): |
|
|
|
|
if modifier.contract != contract: |
|
|
|
|
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) |
|
|
|
|
self.log(info) |
|
|
|
|
|
|
|
|
|