Semgrep: Autofix eats up parentheses and brackets

Created on 27 May 2020  路  8Comments  路  Source: returntocorp/semgrep

Describe the bug
Autofix on Python seems to sometimes eat parentheses and brackets, making code very semantically different

To Reproduce
https://semgrep.live/2Y0

^ this is a simple repro, where I'm trying to replace
self.assertEquals(foo(), 1) with assert foo() == 1, but I end up with assert foo == 1.

(I would have labelled this issue but I don't seem to have the right permissions...)

bug external-user autofix fixed

Most helpful comment

very cool. We'll get on it!

All 8 comments

Thanks @rtpg for the issue. We鈥檙e on it. What timeline do you like a fix? Does the end of the week work ok if it鈥檚 a minor fix?

Nothing is burning of course, but if you are able to provide even a minor fix I would be able to run this across a pretty large codebase and report back on how successful the patch is.

very cool. We'll get on it!

@DrewDennison if there ends up being even a WIP branch that potentially fixes this, I'm willing to try running out to confirm that it doesn't introduce any issues. Please freel free to ping me

Yep, it is more difficult than expected. Hopefully we can get a fix in the next few weeks.

@rtpg This is fixed now for the sample provided. Mind taking a look and letting us know as you run in issues?

https://semgrep.live/r650/ Based on this example, this issue is still not really fixed for brackets.

image

(Basically the brackets disappear upon being replaced, does some especially nasty stuff on JSON objects)

@rtpg Thank you for the follow-up and excellent live example. I opened https://github.com/returntocorp/semgrep/issues/1285 to track further fixes here 馃檹

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mandawi picture Mandawi  路  4Comments

ievans picture ievans  路  5Comments

DrewDennison picture DrewDennison  路  3Comments

DrewDennison picture DrewDennison  路  4Comments

nbrahms picture nbrahms  路  5Comments