Skip to content

Commit

Permalink
rule_var_multilineindent: fix(): Fix bug that caused index to go out …
Browse files Browse the repository at this point in the history
…of bounds

Signed-off-by: Pawel Langowski <[email protected]>
  • Loading branch information
PLangowski authored and priv-kweihmann committed Jun 27, 2024
1 parent 695ebd1 commit 06f98cb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions oelint_adv/rule_base/rule_var_multilineindent.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ def fix(self, _file: str, stash: Stash) -> List[str]:
_likeliest_indent, _indent_map = self.__line_stats(i.VarValueStripped, i.VarNameComplete, i.VarOp)
_likeliest_indent = max(4, _likeliest_indent)
_lines = i.RealRaw.splitlines()
# _lines = [x for x in RegexRpl.split(r'\t|\x1b', i.RealRaw) if x and x.strip()]
found = False
for index, value in enumerate(_indent_map):
if value != _likeliest_indent:
i.Raw = i.Raw.replace(_lines[index + 1], " " * _likeliest_indent + _lines[index + 1].lstrip())
i.RealRaw = i.RealRaw.replace(_lines[index + 1], " " * _likeliest_indent + _lines[index + 1].lstrip())
if value != _likeliest_indent and index != 0:
found = True
_lines[index] = " " * _likeliest_indent + _lines[index].lstrip()
res.append(_file)
if found:
i.Raw = "\n".join(_lines)
i.RealRaw = "\n".join(_lines)
return res

0 comments on commit 06f98cb

Please sign in to comment.