konobi / kwalitee

Package for measuring node package kwalitee
MIT License
12 stars 5 forks source link

Some metrics of package quality #1

Open ljharb opened 9 years ago

ljharb commented 9 years ago

Per your request:

iarna commented 9 years ago

So caveats:

piranna commented 8 years ago

Of course, follow semver scrupulously. Known breaking changes must bump a major version. Any functionality or API additions must be in a minor bump. Everything else is a patch. Any breakages discovered must be rolled back and ported to the next major version. etc.

On 0.x.y versions, the x should define backward incompatible API changes, the same way as major versions on post-1.0.0 releases.

konobi commented 8 years ago

All we can check is that the version is valid semver.

piranna commented 8 years ago

APIs could somewhat be check by analizing the methods and their parameters and see if they are added or they change, in that last case it should be in a new major version (or new 0.x). It could be also done to check deleted methods and params and show a warning if they were not marked as deprecated in a previous version.

konobi commented 8 years ago

If you can think of a way of doing that statically from an unbundled package tarball/repo, I'd certainly be interested.

piranna commented 8 years ago

Maybe using esprima or something similar... For prototype defined ones should be somewhat easy, for instance methods (this.foo = function(){}) would need more checking, but I think it's doable up to some degree.

piranna commented 8 years ago

Obviously being Javascript a dynamic language this could never be bullet-proof, but a statically analisis could be done in a high percentace of situations.

konobi commented 8 years ago

yeah, I already have some need for esprima to come along at some point... but this is probably one of those spots where a PR would work best (even if it's just tests).

ljharb commented 8 years ago

Look at the exported thing; compare Object.getOwnPropertyNames + Object.getOwnPropertySymbols and the typeof of their values (and name and length if they're functions, etc going into more depth if the types match), and then do the same walking up the prototype chain. That should allow you to produce a digest hash, as well as determine when observable properties are added, or deleted.

Added would guarantee at least a minor - deleted would guarantee a major - no observable changes is likely a patch.

Obviously for 0.x versions (which nobody should still be using anyways; dock them for that regardless), obviously the second number is for breaking changes, and the third for additions.