Skip to content

Uninitialized Variables (original, replace) When file_loc_intervals is Empty #76

@Xc1ord

Description

@Xc1ord

There is a bug in processing len(file_loc_intervals) == 0, the variables original and replace referenced before being assigned.

if len(file_loc_intervals) == 0:
if original in content:
content = content.replace(original, replace)
replaced = True
else:
print("not replaced")
return content

Maybe it should be like this? Assign the entire file content as a single interval when file_loc_intervals is empty.

 if len(file_loc_intervals) == 0:
        total_lines = len(content.splitlines())
        file_loc_intervals = [(1, total_lines)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions