Code Quality
Tooling & ideas for fixing up code
There’s a lot of code online, or maybe at your job; that’s been poorly maintained, fallen out-of-date with newer libraries and/or compilers, and may not even be operating as desired currently. This is an attempt to highlight what I’ve found over the past 2-3 years to help myself with sorting this stuff out; and have recommended to others separately. Side note: when introducing to code, try adding any of these as a commit, separate to any code changes; this creates a good fallback point if any bugfixes don’t work out right.
Other / Multi#
- SonarLint: this works with C#, JS, and a few other languages for best practices in said coding.
- Git (git-scm.com): if you’re not using something else already (eyes Perforce warily), get up to speed on this. Key commands:
git pull;git push;git rebase -i(HEAD~# or commit ID);git cherry-pick(commit ID) - Check your IDE for any plugins that support the below suggestions; they may also have built-in formatting tools.
C##
Assuming use of Visual Studio, but other IDEs should support nugets of these.
- Roslynator: heavy-duty C# linter.
- Sharpen: if using VS 2017/2019, this is a cool tool to figure out newer C# features; works up to C# 8.
- Clr Heap Allocation Analyzer: VS2017/2019, 2022-pending tool for reviewing memory allocation.
- IDisposableAnalyzers: object disposal validation
- ReflectionAnalyzers: type/class validation
- ThreadingAnalyzers: to avoid issues with parallel / multitasking / threading.
- Unity Analyzers: to find gotchas in Unity-based games and apps.
- Sample .editorconfig that can be applied & modified with apps & analyzers.
- LINQ compiler / optimizer
JavaScript#
Assuming use of VS Code and/or NodeJS, but your environment may vary.
- ESLint: the standard for linting JavaScript.
- StandardJS: widely used formatting practice for JS code.
- ESLint plugin for StandardJS; allows you to format code as StandardJS, but clear more serious errors too.
- ESLint plugin to suggest reductions in use of Lodash & Underscore: use this one carefully; eslint-plugin-more is a good alternative.
- ESLint plugin to identify problems with promise chains: Mozilla has a good explanation of how they work.
- ESLint plugin to validate ternary operators: if-else can be replaced by
? :, but it gets tricky. - ESLint plugin to translate ES2015+ error messages
- ESLint plugin to suggest arrow function use
- “Unicorn” ESLint plugin
- P42: AI/ML-assisted JavaScript linter service.
- CJS-ES6: tool to format pre-ES2015 files to newer standard.
- JSHint: another JS analyzer for multiple environments.
Libraries that might help#
- all-of-just: this is a compendium of a single-function library, that assorted folks use for JS tasks; requires ES2015+.
- already: use this to replace most of the Bluebird library and be able to call native Promises.
- Supercharge: complete replacement of the fs/fs-extra libraries; some care needed to make use of.
Bash & Batch#
Python#
- PyLint
- pep8: checks code against the approved Python standard.
- Black: basically StandardJS for Python.
- wemake-python-styleguide: recommended via Reddit
C++#
- Cppcheck: a static-analysis tool for C/C++ code.
- Clang-Tidy: recommended via Reddit
Read other posts