Comby - Structural code search and replace for every language
comby.dev
comby.dev
Curious whether the teams behind these tools are aware of each other? I suppose it's unlikely that they're not.
i found the CLI features lacking in semgrep (vs using a yaml config), so maybe this will have more support there.
Does someone know if this or something similar is available as a VSCode extension? It'd be fun to make one if not!
Swiping fiasco. When do we get the edit comment feature in HN? :)
You can't do batch changes[2] inside of VSCode yet, only via the Sourcegraph CLI[3]. We're working on expanding this.
[1] https://marketplace.visualstudio.com/items?itemName=sourcegr... [2] https://docs.sourcegraph.com/batch_changes/explanations/intr... [3] https://docs.sourcegraph.com/cli
[1] https://docs.sourcegraph.com/cli [2] https://github.com/sourcegraph/sourcegraph/issues/new?assign...
We also have a few tutorials to make large-scale code changes across many repositories and code hosts (batch changes) with Comby:
- Refactor Go code using Comby: https://docs.sourcegraph.com/batch_changes/tutorials/refacto...
- Updating Go import statements using Comby: https://docs.sourcegraph.com/batch_changes/tutorials/updatin...
The author of Comby is a researcher at Sourcegraph building our search platform.
Also, how does it compare to Coccinelle?
They have a comparison section in their faq (https://comby.dev/docs/faq):
"Coccinelle uses a declarative syntax for matching constructs like function calls, if-statements, expression blocks, and so on for the C language. Some notable differences are that Coccinelle provides a patch-like format to express transformations (handy when you want to inline smaller changes in a broader context) and metavariable declarations (handy for developing and organizing more sophisticated patterns). For an example, see the file null_ref.cocci. Coccinelle works only for the C language, and may struggle to parse files that contain non-standard C constructs, like GCC inline assembly. Recent Coccinelle work has started expanding support for Java. In contrast, Comby’s syntax targets a wide range of languages and is more robust to matching patterns in the presence of unrecognized constructs. Comby is more suited to writing quick find-replace patterns for languages beyond C, and works well on C languages too."
> Dedicated parsers refine how Comby understands code, but it also has basic out-of-the-box support for data formats like JSON, recent languages like Zig, or your own DSLs!