|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta content="width=device-width, initial-scale=1" name="viewport"> |
| 6 | + <meta content="Lint early, lint often" name="title" property="og:title"> |
| 7 | + <meta content="article" name="type" property="og:type"> |
| 8 | + <meta content="/theme/images/agile_sysadmin.webp" name="type" property="og:image"> |
| 9 | + <meta content="https://blog.ferki.it/2025/02/03/lint-early-lint-often/index.html" name="url" property="og:url"> |
| 10 | + <meta content="Ferenc Erki - agile sysadmin" name="description"> |
| 11 | + <meta content="Ferenc Erki" name="author"> |
| 12 | + <meta content="4KzbYclokErOfwrKiBpX8XCu8ckJ9A7zwueL9VAbAYE" name="google-site-verification"> |
| 13 | + <link href="/theme/images/favicon.svg" rel="icon"> |
| 14 | + <link href="/theme/css/selenized.css" rel="stylesheet"> |
| 15 | + <script data-domain="blog.ferki.it" defer src="https://plausible.io/js/script.js"></script> |
| 16 | + <title>Lint early, lint often</title> |
| 17 | + </head> |
| 18 | + <body> |
| 19 | + <header> |
| 20 | + <h1><a href="/">🧑💻 agile sysadmin</a></h1> |
| 21 | + <p>by Ferenc Erki</p> |
| 22 | + </header> |
| 23 | + |
| 24 | + <nav> |
| 25 | + <ul> |
| 26 | + <li><a href="/pages/about.html">About</a></li> |
| 27 | + <li><a href="/">Posts</a></li> |
| 28 | + <li><a href="https://ferki.it" target="_blank">Homepage</a></li> |
| 29 | + <li><a href="https://cal.com/ferki" target="_blank">Booking</a></li> |
| 30 | + </ul> |
| 31 | + </nav> |
| 32 | + |
| 33 | + <main> |
| 34 | + <article> |
| 35 | + |
| 36 | + <header> |
| 37 | + <h1><a href="/2025/02/03/lint-early-lint-often/">Lint early, lint often</a></h1> |
| 38 | + |
| 39 | + <aside> |
| 40 | + <time datetime="2025-02-03" title="published"> |
| 41 | + 🗓 2025-02-03 |
| 42 | + </time> |
| 43 | + <a href="/tag/linting/">#linting</a> |
| 44 | + <a href="/tag/static-analysis/">#static analysis</a> |
| 45 | + </aside> |
| 46 | + |
| 47 | +</header> |
| 48 | + |
| 49 | + |
| 50 | + <section id="section-1"> |
| 51 | + <p>Wikipedia defines <a href="https://en.wikipedia.org/wiki/Lint_(software)">linting |
| 52 | +software</a> as:</p> |
| 53 | + |
| 54 | +<blockquote> |
| 55 | + <p>a static code analysis tool used to flag programming errors, bugs, stylistic |
| 56 | + errors and suspicious constructs.</p> |
| 57 | +</blockquote> |
| 58 | + |
| 59 | +<p>Linters play an important role to detect common mistakes fast. I often find |
| 60 | +that running them first in the build pipelines happens already too late, |
| 61 | +reducing their usefulness.</p> |
| 62 | + |
| 63 | +<p>When to lint to maximize their value?</p> |
| 64 | + |
| 65 | + </section> |
| 66 | + <section id="section-2"> |
| 67 | + <p>Software change processes commonly involve the following steps before |
| 68 | +triggering a pipeline for automated tests:</p> |
| 69 | + |
| 70 | +<ul> |
| 71 | +<li>change some code</li> |
| 72 | +<li>save the file</li> |
| 73 | +<li>run local tests</li> |
| 74 | +<li>commit changes to version control</li> |
| 75 | +<li>push the changes to the main repository</li> |
| 76 | +</ul> |
| 77 | + |
| 78 | +<p>When linters find a problem during the pipeline steps, it leads to considerable |
| 79 | +delays: I already done the work, I have to get back to context, apply a fix, |
| 80 | +save the changes, run local tests, make new commits, and start the pipeline |
| 81 | +again.</p> |
| 82 | + |
| 83 | +<p>Let’s find a way to do it earlier then.</p> |
| 84 | + |
| 85 | +<p>How about before pushing changes? Or before making commits? As part of the |
| 86 | +local tests? Upon saving files? We can do even better!</p> |
| 87 | + |
| 88 | +<p>I prefer to configure my editor to run linters asynchronously as I type, and |
| 89 | +show the results in its UI. That way I get instant feedback about my work. At |
| 90 | +my fingertips. In most cases even before saving the file I work with.</p> |
| 91 | + |
| 92 | +<p>For example I use Vim with the <a href="https://github.com/dense-analysis/ale">Asynchronous Lint |
| 93 | +Engine</a> plugin. Which <a href="https://github.com/dense-analysis/ale/blob/master/supported-tools.md">supports many |
| 94 | +languages</a> |
| 95 | +and their linting tools.</p> |
| 96 | + |
| 97 | +<p>Having such frictionless and immediate feedback about what I type helps |
| 98 | +tremendously.</p> |
| 99 | + |
| 100 | +<p>I recommend to lint as early and as often as possible.</p> |
| 101 | + |
| 102 | +<p>Shift left.</p> |
| 103 | + |
| 104 | + </section> |
| 105 | + |
| 106 | +</article> |
| 107 | + |
| 108 | +<ul class="pager"> |
| 109 | + <li class="prev"> |
| 110 | + <a href="/2024/07/25/packaging-go-dependencies-for-gentoo/index.html" rel="prev"> |
| 111 | + ← Older |
| 112 | + </a> |
| 113 | + </li> |
| 114 | + <li class="next"> |
| 115 | + </li> |
| 116 | +</ul> |
| 117 | + |
| 118 | + |
| 119 | + </main> |
| 120 | + |
| 121 | + <footer> |
| 122 | + |
| 123 | + <ul> |
| 124 | + <li><a href="https://blog.ferki.it/index.rss" target="_blank">RSS</a></li> |
| 125 | + <li><a href="https://blog.ferki.it/index.atom" target="_blank">Atom</a></li> |
| 126 | + <li><a href="https://github.com/ferki" rel="me" target="_blank">GitHub</a></li> |
| 127 | + <li><a href="https://profile.codersrank.io/user/ferki" rel="me" target="_blank">CodersRank</a></li> |
| 128 | + <li><a href="https://www.linkedin.com/in/ferki" rel="me" target="_blank">LinkedIn</a></li> |
| 129 | + <li><a href="https://fosstodon.org/@ferki" rel="me" target="_blank">Mastodon</a></li> |
| 130 | + <li><a href="mailto:ferki@ferki.it">Email</a></li> |
| 131 | + <li><a href="/pages/impressum.html">Impressum</a></li> |
| 132 | + <li><a href="/pages/privacy_policy.html">Privacy policy</a></li> |
| 133 | + </ul> |
| 134 | + <ul> |
| 135 | + <li>© 2023–2025 Ferenc Erki</li> |
| 136 | + </ul> |
| 137 | + |
| 138 | + </footer> |
| 139 | + </body> |
| 140 | +</html> |
0 commit comments