The Sonar team is pleased to announce Sonar 2.0. The main feature in Sonar 2.0 consists of analyzing Design : Architecture and Object Oriented Metrics. This enables to report on the “7th deadly sin of the developer” that was missing so far in Sonar. As a reminder, here are the first six deadly sins : low coverage by unit tests, bad complexity distribution, potential bugs, duplicated code, lack of comments and non respect of coding standards.
Here is a presentation of the new version in screenshots :
When talking about architecture the first priority is to remove cycles between packages by cutting undesired dependencies. That might sound like an evidence but among all well-known java projects continuously analyzed and available in Nemo, very few of them don’t have cycles. The cycle concept is just a familiar entry point into Sonar which leads to more powerful information : how many dependencies between packages should be cut in order to remove all cycles ? How tangled is the overall architecture ? How many links between files do those dependencies represent ?
From the project dashboard, clicking on any above ‘architecture’ metrics, leads to a new visual tool : The DSM (Dependency Structure Matrix). DSM is a compact way to represent and navigate across dependencies between components. Depending on the navigation level, those components can be Maven modules, packages or files. Wants to know more about the DSM ? Here is the DSM user guide.
All Chidamber & Kemerer metrics are now available in Sonar : DIT, NOC, RFC, CA, CE, LCOM4. The most interesting Object Oriented metric is certainly LCOM4 (Lack of Cohesion of Methods) which can be used to hunt classes undertaking too many responsibilities.
Let’s take a simple example : a class whose LCOM4=3 means that 3 different blocks of methods/fields are fully unrelated and so the class is not cohesive. Of course this is possible to visualize those blocks into the resource viewer :
Last but not least, all the underlying mechanisms used to extract dependencies graph from Bytecode, compute object-oriented metrics, create and sort the DSM, target dependencies to cut have been fully implemented in Squid by the Sonar team. This will allow to provide new features like dead code detection, calls to deprecated methods, architecture rules engine in future Sonar versions.
To find out more about Sonar 2.0 and the 50 issues that have been fixed, you can read the release note or maybe you prefer to download it to give a ride !