So when I have finished the first version of the plugin, and I sent it back to the troop who is responsible for Sonar, I realized they would not accept it... Meanwhile they created a tool called SSLR (SonarSource Language Recognizer), which is a framework to create lexers, parsers, and AST visitors for any language... So I have decided to create a new version, where I parse the source codes and build up an AST tree...
Chapter 1:
During that phase, it was around Sept., Oct., it took me a while to create the parser, because I am not really experienced in erlang, but with the tool you can easily follow TDD, so basically your job is:
- create a grammar implementation what you think is good
- find some erlang code (github droid is your friend)
- try to parse it
- fix your grammar
- repeat step 3.-4. until you can parse it
- refactor your grammar, to make it more beautiful, better
- check the file again
- continue with other file
So it is really not difficult. After a month I was able to create the first version, after that I had to create some rules, based on the needs of the developers in the team, also integrate it with sonar through a new sonar plugin, but in general (not counting a few hard days) it was straightforward.
So after I have done everything, I sent them an email: Hey guys, here is a language plugin with sslr for erlang, what do you think?
And I was right, they accepted it (after a few fixes).... https://github.com/SonarCommunity/sonar-erlang
And it has the version 0.x, you can get it from the upgrade center.
Chapter 2:
I forget to mention, but the previous thing was a lexerful parser, and during my implementation the troop created a better and faster, and more shiny way to parse source files, and it is a lexerless way... so a few months ago, I migrated all I did before to the new way, including the unit tests... and it is also released...
Chapter 3:
so whats next? creating more checks for sure, and there is some dirty things in the grammar what I want to remove/refactor, but I did not have time yet. And it is not that easy.
And there is a bug in the library sensor, so not all kind of urls are recognized, parsed, which pollutes the sonar db with useless junks in the dependencies...
And I should advertise it to other Regiments/Battalions/Platoons/whatever which use erlang, to gather more feedback, but it also means more responsibility...
That's all folks...