Sonar is an open platform to manage code quality. As such, it covers the 7 axes of
code quality
Sonar itself is implemented in Java (ough, sweet-sweet Java beans). Here
the are some of the supported languages and platforms (on the moment of writing) and the list goes on:
C-Sharp Ecosystem, CXX (C++ languages), Delphi, Flex, Groovy, JavaScript, PHP, Python, Web (JSP, JSF), XML.
Why Sonar indeed?
Reason I - community, maturity, acceptance
It’s quite difficult to answer it in two words. Sonar is platform, rather than tool and I am quite confident it already
does everything you need. And if it doesn’t - you easily could code it yourself in a couple of days/weeks
(rule of thumb - if it something the Sonar community needs as well, it’s very likely
@sonarsource will include it in upcoming release).
As the whole Sonar team is very agile (frequent releases) and very friendly. It’s not
surprise why it’s becoming de-facto standard (e.g. mentioned in Thoughworks Technology Radar
Reason II - previous experience
I’ve already used Sonar on several Java projects and liked it very much. I liked it so much you could say I was
overexcited. So, objective judgement may not be so objective after all. My previous experience have taught me what I
could ask almost every question about project codebase and Sonar, my reliable servant, will give me correct answer back.
We used it to track project technical debt, code metrics, issues per component/subsystem, comment ratio etc..
Within Sonar it was quite easy for us to setup Sprint/Release quality improvement goal and keep it on track during our
daily code commits.
30 min showcase sprint
During 30min showcase:
Sonar downloaded and installed
C# ecosystem support added
Test project is getting analyzed
Why 30 minutes? It’s simple:
in general case it’s hard to persuade upper management to give your more time to such experiments (not my case though)
it’s better to time-box such exercise (thus you don’t waste your time on anything else unrelated and you keep focused
on getting bare minimum done and fine-working)
you better oversee benefit/investment ratio
it’s just amazingly shocking how fast you get difficult things up and running nowadays (kudos @sonarsource team)
The only prerequisite to run Sonar is to have Java (Oracle JDK 1.5 onwards) installed on your machine.
Download ant unzip it to C:\sonar-3.1.1
Execute c:\sonar-3.1.1\bin\windows-x86-32\StartSonar.bat
The expected output should look like
NB - in my case it’s Win7, 32. Please see sibling folders for other options, such as Win 64x. The bin folder contains
much more useful scripts, such as InstallNTService.bat etc.. Please see Sonar documentation for more info.
Vuala, you are all set. You have minimal working instance under your belt. Of course, it’s not production ready
(default configs are for sissies). In real world you MUSTconfigure Sonar instance database at least.
Unzip CSharpPluginsEcosystem-1.3.zip and copy the following jars to /extensions/plugins folder of Sonar
You might want to copy all the jars, however some of the plugins require additionals tools to be installed, which
definitely won’t fit in our 30 min time-box (See install page for
more info).
Relaunch c:\sonar-3.1.1\bin\windows-x86-32\StartSonar.bat to ensure everything starts as before.
Analyze test project
Visit and download latest Simple Java Runner
(1.3 at the moment of writing)
Create file sonar-project.properties with the following content:
Place sonar-project.properties to you project/solution root folder
Change you working directory to you project/solution root folder and execute sonar-runner.bat
NB: It warns us about built-in database usage again. It’s something should re-configured indeed in production use.
01:48:52.885 WARN .c.p.DefaultDatabase - Derby database should be used for evaluation purpose only