开发者

Specific software metrics for Clojure programs

We are considering writing a static analyzer to collect software metrics for Clojure code. Of course it will handle the obvious stuff like number of files, functions, parameters per func开发者_JS百科tion, etc. I wonder if there are any metrics that are specific for Clojure code. Any ideas?


On average - I think that software metrics are a dubious idea - they usually distract you from the really important question which is "how much value are we delivering to the customer??".

Having said that, I recognise they can be a necessary evil in some contexts and can occasionally give you some useful insights about your code base.

So here's a few that might be Clojure-specific.

  • Number of top-level defines (perhaps expressed as a ratio to total symbol count?)
  • Java coupling: % of symbols related to Java interop (new, ClassName., .someMethod etc.) - ideally keep coupling confined to specific modules responsible for Java interop, i.e. should be verey low % everywhere except libraries that manage the interop.
  • Average maximum nesting level of function defns (I guess 5ish good, 10+ bad??)
  • Macro density: % of forms that require macro expansion
  • % of functions with docstrings
  • % of symbols or function parameters defined with type hints
  • Average size of anonymous functions (these should probably be small!)
  • % of functions in clojure.core used (gives some idea of the "vocabulary range" and sophistication of the code)
  • (Thanks nickik!) number of ref-types created (dynamic vars, atom, ref and agent) - essential if you want to keep careful control of your mutable state!

p.s. if you get this working it would be really interesting to see the variation in results across some of the different open source clojure projects!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜