V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
ALLROBOT
V2EX  ›  问与答

semgrep VS ast-grep 代码搜索重构工具,哪个更好用?

  •  1
     
  •   ALLROBOT · May 26, 2024 · 1660 views
    This topic created in 702 days ago, the information mentioned may be changed or developed.
    https://github.com/ast-grep/ast-grep
    https://github.com/semgrep/semgrep

    两个都是代码搜索,然后重构,有别于正则表达式搜索替换的工具

    有用过的人说一下使用体验吗?感觉两者相比如何,哪个用起来更方便
    4 replies    2024-06-12 03:27:02 +08:00
    Al0rid4l
        1
    Al0rid4l  
       May 26, 2024
    在用 ast-grep, semgrep 没有过, 看起来 ast-grep 更简单一点

    作者 @hdnvim 自己的评价在 /t/1006506
    hdnvim
        2
    hdnvim  
       Jun 12, 2024
    谢谢提问!如果是做搜索和重构的话,推荐 ast-grep ,ast-grep 的重写有更多选项。如果是要做安全审计的话可以试试 semgrep 。
    hdnvim
        3
    hdnvim  
       Jun 12, 2024
    @hdnvim ast-grep 有专门文档记录怎么重写代码 https://ast-grep.github.io/guide/rewrite-code.html

    semgrep 相对而言 fix 还比较 experimental
    hdnvim
        4
    hdnvim  
       Jun 12, 2024
    @Al0rid4l 谢谢推荐!!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6155 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 61ms · UTC 02:12 · PVG 10:12 · LAX 19:12 · JFK 22:12
    ♥ Do have faith in what you're doing.