My other blog (in Hungarian) merhetetlen.blogspot.com

Wednesday 18 July 2012

Sonar and Erlang... what have I done?!

It started long time ago...
After a week on Dagobah (endless rain) where I spent my holidays with my little clones and my wife, it is time to tell you my last great(?) achievement. BTW next year we go to a more sunny place like Tatooine (maybe too sunny) or Naboo (somewhere in the middle). But go back to the topic:

everything was started with my transfer to a new battleship, I have to start this from the beginning otherwise I will lost the thread. So as a home project, while my family went back to Naboo or a place like that, I was able to work on it at home as well. The problem with adding something to Sonar, the lack of documentation. There are no step-by-step howtos, how to use the violation part, or how to create measures and so on, but there are a plugins what you can use as a reference... The problem is with that, that every plugin uses the same (or older, deprecated) methods in a different way... it means that the copy-paste not always a good idea, but at least a good starting point. My dear old ex-fellow Alex was a real copy-paste programmer, I hope he is still fighting for the Republic! SO I have no problem with copy-pasting in this case, otherwise you cannot make it work, and you cannot try out code snippets.

Today the plugin is really cool. Next to the basic static analysis (lines of code, number of lines, comments, comment density, number of files, methods, exported methods, public documented APIs, etc...), I could import eunit results (unit test success, unit test coverage), and metrics from an erlang analyzer tool, (what was created by people from the same cloning machine where I was created) like complexity, cohesion... (some of these: http://pnyf.inf.elte.hu/trac/refactorerl/wiki/MetricQuery) so now you can get a quite good overall picture about your erlang software. It also has violation reports, based upon dialyzer and refactorerl things.
So I have reached the state where it is not too easy to extend the plugin...the question, what else do we want? Is it anything more what we can do? Well sometimes I am a compulsive guy, and I cannot let go what I have doubts about, what I don't feel complete. There are some obvious part: IT test, and its coverage... the problem here, is what the hack is IT test? To me, in my term the IT test can be something like acceptance test, so not just IT testing in small, but in big, or you know what I mean. Now it is not clear how to measure coverage for the second phrase, so I think I will implement the IT testing in small cover results... this is one... the other one, or two is about refactorerl... it has some metric what are not close to violations, but real metrics, what we (maybe) want to measure and display (number of imported modules, number of OTP modules and so on...) These things needs a widget to display them... I have started to work on it, but it is a completely different part of sonar, so I have to start over...
Another thing is that refactorerl can generate exciting graph about your code, about dataflow, method calls, and a few more. These are really cool, but to big for a simple code, so I have to find a way to generate something which is smaller and we can display it in another widget...

So this is what we have, now it needs some advertisement, maybe others can use it as well...

oh I forget about the limitations...
the first one it is a little bit against the sonar concept, but it has really strong dependencies for external applications, like dialyzer and refactorerl... but this is the way how it works, there is no chance to remove them with reasonable effort.
It is strongly works in the way how we build and think about our erlang applications... maybe it cannot work on other stuffs of other corps...

so here is a picture about an erlang app (with submodules) dashboard:


if you want it, come and get it

my next post will be about some technical things how we actually analyse and call sonar on our projects (three different way)