Describe the bug
Incorrect chunks of the file are auto-fixed. Searching for assert_eq(True, $X) and replacing with assert $X will mangle the output when auto-fixing multiple multi-line matches.
To Reproduce
https://semgrep.dev/s/juliusdegesys:asserteqbug
Input file:
assert_eq(
True, "a"
)
assert_eq(
True, "b"
)
x = "abc"
Rule:
rules:
- id: assert_eq-true
message: Change assert_eq(True, x) to assert x
severity: INFO
languages:
- python
pattern: assert_eq(True, $ACTUAL)
fix: assert $ACTUAL
The matches look correct, and so do the auto-fixes. But when you "Apply all fixes" or apply the first fix followed by the second, the following output is generated:
assert "a"
assert_eq(
True, "b"
assert "b"
Expected behavior
assert "a"
assert "b"
x = "abc"
What is the priority of the bug to you?
Environment
If not using semgrep.dev: are you running off docker, an official binary, a local build?
pip install semgrep
$ semgrep --version
0.56.0
Describe the bug
Incorrect chunks of the file are auto-fixed. Searching for
assert_eq(True, $X)and replacing withassert $Xwill mangle the output when auto-fixing multiple multi-line matches.To Reproduce
https://semgrep.dev/s/juliusdegesys:asserteqbug
Input file:
Rule:
The matches look correct, and so do the auto-fixes. But when you "Apply all fixes" or apply the first fix followed by the second, the following output is generated:
Expected behavior
What is the priority of the bug to you?
Environment
If not using semgrep.dev: are you running off docker, an official binary, a local build?