Automate your code fixes
Stop fixing code by hand and automate it. In this post, we’ll show you how.
Why you should automate code fixes
There’s 3 reasons:
1 - Reduce RSI. Fixing code by hand requires a lot of typing. As a programmer, you already type too much, so anything that reduces your typing is good for the health of your hands.
2 - Automated fixers type faster. Don’t try to compete.
3 - Automated fixers are more accurate than you. You’ll miss cases, make mistakes. Automated fixers don’t.
Code Formatters
Most of the time, there’s a code formatter that already does the fix you want. Some are built into programs like atom or VSCode. Some are standalone which works well if you’re using vi. Some are configurable to adhere to variations of a specific standard. Here are some examples of stand alone formatters:
JavaScript: eslint
Python: autopep8 (use with -i)
Go: go fmt
Ruby: rubocop
C/C++: clang-format
Java: uncrustify
CSS: stylelint
HTML: tidy
Scheme: scheme-format (not yet complete)
JSON: json-formatter (jq -S '.')
XML: xmll…