Watch out for linters introducing errors

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the workflows category.

Last Updated: 2024-05-01

When I was browsing the DocSplit source code in VIM, I added a debugger and saved the file. From then on the code acted extremely strangely, failing for unrelated reasons - even after I removed the debugger.

What happened? When I saved the code to add the debugger, my linter "fixed" on save using rubocop. The default rules changed $? to CHILD_PROCESS. These are not equivalent, therefore a check for $? == 0 within the code failed and the code bugged out.

The fix was to introduce a vim function to completely disabled linting and use this when I want to be non-invasive. Additionally, it would also be useful if VIM told me when a fixer made a change. Perhaps if I paid more attention to the git signals I would have caught it.