5 ms·
> The product of this process will be a mature core of libraries together with a set of API guidelines that Rust authors can follow to gain insight into the des
by wyldfire 10y ago
> The product of this process will be a mature core of libraries together with a set of API guidelines that Rust authors can follow to gain insight into the design of Rust and level up crates of their own interest.
Is there a plan to make these things statically checkable by rustc/rustfmt/rust-tidy or some sort?
- dtolnay 10y agoYes! The statically checkable ones will be checked by rustc or Clippy. Though some of the guidelines are at a higher level than what those would be able to check. For example: rustc wouldn't be able to tell whether a particular one of your traits would be valuable to make accessible as a trait object.
- Manishearth 10y ago(Also, if this isn't clear, clippy is more than happy to accept PRs for criteria like these.)
- ronjouch 10y agoBeginner question: what would make a crate non-statically-checkable?
- Manishearth 10y agoA guideline like "your tests should test all major functionalities of an API" can't be statically checked for example. It's not about the crate being non checkable, it's about the check being something that needs a human to look at.
- moosingin3space 10y agoI realize that statically checking for tests is reducible to the halting problem, but would it be possible to have some sort of code-coverage checker that would make sure all externally-facing functions have non-zero coverage? That could be used to construct a checklist for a library developer.
- kilotaras 10y agoCode coverage in itself isn't a very useful metric. Classic example is big test with no asserts will get you pretty good coverage. There's a rather computationally intensive technique called mutation testing where you introduce bugs into code (e.g. change + to -, flip conditionals, etc.) and check that tests fail.
- burntsushi 10y agoCode coverage has been useful to me in practice, so I think blanket statements like "code coverage isn't useful" is very misleading. For example, code coverage has helped me identify specific branches in my code that are untested, which in turn help guide me to write additional unit tests. You don't need to completely dismiss other testing techniques. Mutation testing can be useful at the same time that code coverage is useful.
- yazaddaruvala 10y agoTotally agreed. Branch coverage has been far more useful to me than line coverage has.
- Manishearth 10y agoYes, there are code coverage tools and stuff :) This could be used, sure.