The new Wikibase REST API brings standardized and simplified querying and editing of items, properties, statements etc. to Wikibase installations, first and foremost Wikidata. Last year, Wikimedia Sverige was entertaining the idea of a grant application to Wikimedia Deutschland. Part of the proposal was for me to write a Rust crate (i.e. library) for easier access to the new REST API. The project eventually didn’t go ahead, but I had started writing the code anyway, out of personal interest. To make it more chellenging, I tried to apply industry-level coding standards to the project; most of my tools are not written with this in mind, as usually I am the only one working on them.
Now, I have an (almost) feature-complete result:
- The Rust crate
- The github repo
What about those coding standards? Well:
- 248 unit tests in the codebase, running in 0.2sec (on my machine), that are also run on every github push
- many tests mock a HTTP server to allow local testing, including simulated editing
- grcov reports >97% code coverage
- tarpaulin reports ~90% code coverage (but doesn’t see some traits being used when they are)
- cyclomatic complexity mean is 2.1 for the entire codebase, <7 everywhere (according to lizard)
- function line length is <40 lines for the entire codebase
- maintainability index median is 126.3 (original) or 73.9 (VS Code)
- scripts and instructions for calculating the code metrics are part of the repo, as it an analysis.tab file
- passes miri for all of my code (tests using some external code are deactivated for miri)
I will certainly make it a point to use the crate in both new and existing projects. I hope some of you will join me, and please feed back comments and issues on the issue tracker. Pull requests welcome!