Moose demo: detecting wrong values in annotations

Annotations are a means to attach extra information to your source code. For example, in Moose we use them as a means to meta-describe the entities from meta-models such as FAMIX, the central one that models multiple facets of software systems.

Recently, we came to scrutinize the use of these annotations, and came to the conclusion that one of them is used often in an unwanted way. The annotation (or pragma in terms of Smalltalk) in question is <MSEClass:super:>. In particular, the issue is that the second argument should be a symbol and not a simple string.

The reason for why this is the case has to do with deep technical details of the Moose platform. At any rate, the goal of this demo is to provide an idea of how to detect this problem once we know of it.

Essentially, we want to:

  • find the <MSEClass:super:> annotation type
  • identify all instances
  • from these detect those that have as second argument a value that is not symbol.

The video below demonstrates how to express this rule in Moose.

The detection boils down to the following query:

annotation instances select: [:each |
        each attributes second value isSymbol not]

Once we have the query, we can also integrate in a report. The current one can be found in the Moose on Moose report from the dedicated continuous integration Moose server.

Posted by Tudor Girba at 25 September 2011, 6:35 pm with tags moose, demo, assessment link
|