Moose meta-models rely on meta-descriptions defined through annotations attached to the source code. These meta-descriptions are used for various purposes including user interface generation and saving and loading.
Recently, we found a bug in Moose that induced a crash during the loading of certain models. The reason for the crash was that one of the meta-descriptions had a space in the name, like in the code below:
FAMIXMethod>>clientClasses <MSEProperty: 'Client Classes' type: #FAMIXType> <multivalued> ...
Once the model was exported in a file, the property got serialized with a space in the name, and during importing the parser was not happy with it. The correct code should have looked like:
FAMIXMethod>>clientClasses <MSEProperty: #clientClasses type: #FAMIXType> <multivalued> <derived> ...
We could easily write a test to cover this particular case. However, the question remained as to how to prevent this problem to occur in the future. The main problem is that this issue was only seen when exporting the faulty property. In order to ensure that all properties are exported, we would have needed to manufacture tests that generate data for all these properties and ensure that they are semantically correct. This would be an interesting, but also a rather expensive exercise.
A much cheaper solution is to prevent spaces to ever occur in names by checking the information statically. All we had to do was to spawn Moose and point it at Moose using the following rule:
interestingAnnotations := (model allAnnotationTypes select: [ :each | each name beginsWith: #MSEProperty:type:]) flatCollect: #instances. interestingAnnotations select: [ :each | each attributes first value includes: Character space ]
Once we had the checker, we simply integrated it in the regular checker report.