Static Analyzer for Solidity
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
slither/utils/slither_format/format_unused_state.py

19 lines
805 B

class FormatUnusedState:
@staticmethod
def format(slither, patches, elements):
for element in elements:
FormatUnusedState.create_patch(slither, patches, element['source_mapping']['filename'], element['source_mapping']['start'])
@staticmethod
def create_patch(slither, patches, in_file, modify_loc_start):
in_file_str = slither.source_code[in_file]
old_str_of_interest = in_file_str[modify_loc_start:]
patches[in_file].append({
"detector" : "unused-state",
"start" : modify_loc_start,
"end" : modify_loc_start + len(old_str_of_interest.partition(';')[0]) + 1,
"old_string" : old_str_of_interest.partition(';')[0] + old_str_of_interest.partition(';')[1],
"new_string" : ""
})