{"path": "/posts/i-love-comby/", "title": "I love Comby! · Bruno Dias", "html": "<!doctype html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"utf-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  <meta name=\"description\" content=\"I love Comby!\">\n  <title>I love Comby! · Bruno Dias</title>\n  <link rel=\"canonical\" href=\"https://diasbruno.github.io/posts/i-love-comby/\" data-post-metadata>\n  <meta name=\"author\" content=\"Bruno Dias\" data-post-metadata>\n  <meta property=\"og:type\" content=\"article\" data-post-metadata>\n  <meta property=\"og:title\" content=\"I love Comby!\" data-post-metadata>\n  <meta property=\"og:url\" content=\"https://diasbruno.github.io/posts/i-love-comby/\" data-post-metadata>\n  <meta property=\"article:published_time\" content=\"2021-06-08T15:00:00Z\" data-post-metadata>\n  <link rel=\"icon\" href=\"/assets/site/signature.svg\" type=\"image/svg+xml\">\n  <link rel=\"alternate\" type=\"application/atom+xml\" title=\"diasbruno\" href=\"/atom.xml\">\n  <link rel=\"alternate\" type=\"application/json\" href=\"/posts/i-love-comby/content.json\">\n  <link rel=\"stylesheet\" href=\"/assets/site/tokens.css\">\n  <link rel=\"stylesheet\" href=\"/assets/site/site.css\">\n  <link rel=\"stylesheet\" href=\"/assets/site/footer.css\">\n\n</head>\n<body class=\"light\">\n<div id=\"site-page\">\n<a class=\"skip-link\" href=\"#content\">Skip to content</a>\n<header class=\"site-header\">\n  <a class=\"brand\" href=\"/\" data-site-navigation aria-label=\"Bruno Dias, home\">\n    <img src=\"/assets/site/signature.svg\" width=\"24\" height=\"34\" alt=\"\">\n  </a>\n  <nav aria-label=\"Main navigation\">\n    <ul>\n<li><a class=\"nav-vrn\" href=\"/vrn/\" data-site-navigation><span class=\"nav-label\">vrn</span> <span class=\"nav-badge\">research</span></a></li>\n<li><a class=\"nav-posts\" href=\"/posts/\" data-site-navigation aria-current=\"location\">Posts</a></li>\n<li><a class=\"nav-projects\" href=\"/projects/\" data-site-navigation>Projects</a></li>\n<li><a class=\"nav-about\" href=\"/about/\" data-site-navigation>About</a></li>\n</ul>\n  </nav>\n</header>\n\n<main class=\"section\" id=\"content\" tabindex=\"-1\">\n  <article class=\"post-detail\">\n    <header class=\"section-header\">\n      <p class=\"post-category\">Post</p>\n      <h1>I love Comby!</h1>\n\n      <p><time datetime=\"2021-06-08T15:00:00Z\">2021-06-08</time></p>\n    </header>\n    <div class=\"post-columns\">\n      <section class=\"post-body\" aria-label=\"Article\">\n\n<p>I love <a href=\"https://github.com/comby-tools/comby\">Comby</a>, in their words:</p>\n<blockquote>\n<p>&quot;A tool for structural code search and replace\nthat supports ~every language.&quot;</p>\n</blockquote>\n<p>Most of the time when I'm reviewing some pull request,\nI always have the same thoughts:</p>\n<ul>\n<li>&quot;I've seem this before...&quot;</li>\n<li>&quot;I see a pattern here...&quot;</li>\n</ul>\n<p>And then I:</p>\n<ul>\n<li>Go to the project folder.</li>\n<li>Update the repository.</li>\n<li>Go to the PR's branch.</li>\n<li>Figure out a <code>grep</code> that can extract what I want.</li>\n</ul>\n<p>As we all know, step 4 is the one that takes a lot of time.</p>\n<p><code>comby</code> understands a little bit of syntax and deals well\nbalancing <code>()</code>, <code>[]</code> and <code>{}</code>,\nwhich is the most painful thing to do when writing regex.</p>\n<p>Example:</p>\n<p>After some interactions on our software, we had many methods related to permissions written on views\nand components. Eventually, things starts getting duplicated, so it was time to refactor/reorganize.</p>\n<p>Using comby, this was basically (or close) of what I had to type:</p>\n<pre><code>comby 'can:[~[A-Za-z0-9_]*](:[h]) {:[i]}' '' -matcher .js\n</code></pre>\n<p>Output example:</p>\n<pre><code>------ file.vue\n++++++ file.vue\n@|-1,5 +1,3 ============================================================\n |  computed: {\n!|     canEdit() {\n!|       return this.user.permissions.contains(Permissions.X);\n!|     }\n |  }\n</code></pre>\n<p>This expression highlights every function/method\nthat is prefixed with 'can' (<code>:[h]</code> and <code>:[I]</code>\nare just placeholders saying &quot;whatever is in between\nthe parenthesis and curly brackets&quot;).</p>\n<p>With the result in hand, I show to the team, we discussed\nwhen we could tackle this issue, we had some ideas\nand we start the refactor.</p>\n<p>This is one use case of comby, go checkout their page\nand I hope this will be your favorite tool as it's mine now.</p>\n\n      </section>\n      <aside class=\"post-links\" aria-labelledby=\"post-links-heading\">\n        <h2 id=\"post-links-heading\">Links</h2>\n        <ul>\n<li><a href=\"/posts/\" data-site-navigation>All posts</a></li>\n        </ul>\n      </aside>\n    </div>\n  </article>\n</main>\n\n<footer class=\"site-footer\">\n  <div class=\"site-footer-inner\">\n    <a class=\"site-footer-home\" href=\"/\" data-site-navigation>Bruno Dias</a>\n    <ul aria-label=\"Footer links\">\n      <li><a href=\"https://github.com/diasbruno\">GitHub</a></li>\n      <li><a href=\"/atom.xml\">Atom feed</a></li>\n    </ul>\n  </div>\n</footer>\n\n</div>\n<script type=\"module\" src=\"/assets/site/navigation.js\"></script>\n</body>\n</html>\n"}
