Monday, November 30, 2009

EMF and SMM to export code metrics to Sonar and Squale

How to facilitate the integration between code quality measurement tools and code quality reporting tools ?

This is the problem we are faced with at Mia-Software: to address modernization projects, we have developped a lot of parsers creating models of code from which we can compute quality metrics (from COBOL, Natural or VB6 to Smalltalk, C# or Java). But as our customers are interested in getting these metrics in the quality report tool of their choice, we don't want to multiply the development of adhoc bridges (one for each couple "metrics calculator" <-> "report tool")

To reduce the cost of bridging the tools, we chose SMM (Structured Metrics Metamodel) as a pivot. SMM is the OMG/ADM standard for defining metrics related to software and for representing their measurement on existing systems. Its reference EMF implementation can be found in MoDisco, the Eclipse Modeling project focused on discovering models from software assets.

The main classes defined by SMM are quite simple :
- Measure : the definition of an indicator (nb lines of code, cyclomatic complexity, …)
- Scope : the kind of elements on which the indicator can be measured
- Measurand : an element on which an indicator has been measured
- Measurement : the measured value of an indicator
- Observation : who ? how ? when ?
Then, for each measurement tool that we need to integrate with a report tool, we just have to create a SMM model describing the kind of metrics to exchange (instances of Measure and Scope) and a connector to translate the specific export format of the measurement tool to a SMM model containing the measured values (instances of Measurement, Measurand and Scope).

In parallel, we create one generator for each report tool to integrate with. This generator takes the SMM model defining the measures and generates :

• the files declaring the metrics within the report tool
• the files configuring the report tool to integrate the new kind of metrics
• the source code of the component which will import SMM models containing the measurements
At this time we have experimented this approach to import COBOL and VB6 metrics (calculated by Mia-Insight) into the quality report tools Sonar and Squale.

Screenshots : COBOL -> Sonar

Screenshots : COBOL -> Squale

Our conclusion is that SMM fits the need of integration between these kind of tools.

The next step will be the integration of XRadar (suggestions of other report tools are welcome ;-) ).

We also have to solve the problem of metrics aggregation. There are three possibilities :
- aggregation at measurement time
- aggregation in SMM model
- aggregation in report tool
We have already identified pros and cons for each alternative. Depending on the kind of aggregation to perform, experimentation will probabely give an answer !

Saturday, October 31, 2009

Eclipse Summit Europe 2009

This year was my first attending ESE, and it was worth it !

The talks on modeling were very interesting (Xtext, EMFQuery, Papyrus, ...) and it was nice to meet the guys directly involved in the projects we are interested in.

The Cloudsmith team, for example, to discuss how we could use MoDisco on the B3 project to analyse plugins and create models of builds. Or André Dietisheim about our tests with CDO to manage models of large Java applications created with MoDisco. Nice also to talk with Kenn, Ed, Ralph and many others.

I had the chance to talk during both the Modeling Symposium (Tuesday) and a session dedicated to MoDisco (Thursday).

With my colleague Gabriel Barbier of Mia-Software, who presented the demo Thursday, we shown how to create fine-grained models from Java source code (based on a Java.ecore metamodel), and how to navigate through this model with the model browser we have developped. We put the focus on the customization and the extensibility of this browser by using queries.

You can dynamically change the icon, color, font ... of the instances of your models (by defining a UICustomization, stored in a EMF model), or add "virtual" types (not originally defined in your Ecore metamodel) with "virtual" properties and references (by defining a RoleSet, also stored in a EMF model). The query mechanism that we provide is generic : it allows integrating queries written in Java, EMFQuery, OCL, XPath or ATL.

We presented the 0.8 version which is still under development (planned for the end of 2009). But thanks to Nicolas Bros who have put the releng in place, it is possible to download an integration build.

The demos are online :
- Demo during the Modeling Symposium
- Demo during the MoDisco short talk