Hello NVDA add-ons and development community,
For those new to the community: I’m Joseph Lee, one of the volunteer code contributors to NVDA screen reader project. I hope everyone is staying safe and healthy during this uncertain time.
Like many of you, the ongoing COVID-19 pandemic had a profound impact in my life. After thinking about what to do while juggling online classes, I decided to take a look at the overall health of the NVDA add-ons ecosystem, specifically a way to hunt for bugs and improve code quality and style. The result is Project Blackjack, a set of recommendations for doing just that (linting) with help from Flake8.
As some of you might be aware by now, NVDA project is using Flake8, a popular coding style checker (linter) to deal with coding style. This tool allows us (NVDA contributors) to look at potential issues that can arise from inconsistent coding style, and in some cases, find things that appear to be harmless but are actual bugs (syntax warnings and errors and such). Some of you posting pull requests to GitHub may have noticed messages about Flake8 errors on your code, with the tool asking you to fix issues found.
In April 2020, I decided to run Flake8 against add-ons I have developed so far. Not only this tool found linting issues, it found potential bugs, and in at least two occasions, actual bugs that weren’t obvious at first. Notable finds include error handling logic error in encoder support in StationPlaylist, unused variable in Resource Monitor, and a need to update Weather app module in Windows 10 App Essentials to modern NVDA coding standards. Thanks to this tool, these three add-ons have gone through coding style changes, bug fixes, and passes Flake8 test.
Because linting NVDA source code itself is something that will take months, I propose that add-ons community use Flake8 to look into coding style, and in some cases, hunt for potential and actual bugs. To do this:
For more info on Flake8, take a look at:
Recommended usage while developing and maintaining add-ons:
For NVDA code contributors: to reduce messages you get about Flake8 when you submit pull requests, I recommend doing a local linting and runtime tests first before committing changes. Not only it can reduce Flake8 messages, it can also reduce diffs and let you see that your changes are fine and readable (no regressions, for example).
As a practical demonstration of linting, I will be dedicating upcoming version 20.06 release of my add-ons to Flake8 work. Resource Monitor, StationPlaylist, and Windows 10 App Essentials have gone through linting check in April and they are working as advertised.
If you have any questions, feel free to ask. For coding style for NVDA project, refer to NVDA wiki article on coding style and contributing.