Last active
August 29, 2015 14:16
-
-
Save aranega/f6f0a93c952da88c0d6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import 'https://gist.githubusercontent.com/aranega/03ca7cf65c879e3bf4f3/raw/refact.catsoo' | |
def _logwrap(o : Object, s : String) | |
{ | |
log(s); | |
} | |
def metrics() | |
{ | |
var elems := model objects(); | |
var nbclasses := elems[Class] size(); | |
log('#Class = ' + nbclasses); | |
log(' * abstract = ' + elems[Class]->select(e | e.isAbstract) size()); | |
log(' * concrete = ' + elems[Class]->select(e | not e.isAbstract) size()); | |
log(''); | |
var nbinter := elems[Interface] size(); | |
log('#Interface = ' + nbinter); | |
log(''); | |
var notcontained := elems[Classifier]->select(e | __ROOT.packagedElement contains(e)); | |
log('#Class/Interface not contained in Package = ' + notcontained size()); | |
notcontained->_logwrap(' * ' + self.qualifiedName); | |
log(''); | |
var nonmatch := elems[Class]->select(e | not e.name matches('.*Entity')); | |
log('#Class that do not end with "Entity" = ' + nonmatch size()); | |
nonmatch->_logwrap(' * ' + self.qualifiedName); | |
log(''); | |
var badprop := elems[Property]->select(e | e.type = null); | |
log('#Property w/out type = ' + badprop size()); | |
badprop->_logwrap(' * ' + self.qualifiedName); | |
log(''); | |
log('Misplaced elements = ' + ((notcontained size() / (nbinter + nbclasses) toReal()) * 100.0) + '%'); | |
log('Bad class name = ' + ((nonmatch size() / nbclasses toReal()) * 100.0) + '%'); | |
log('Property w/ missing type = ' + ((badprop size() / elems[Property] size() toReal()) * 100.0) + '%'); | |
} | |
def _uml_cPackage(name : String, x : Integer, y : Integer) : Package | |
{ | |
var p := create Package{name := name}; | |
__ROOT.packagedElement += p; | |
__ROOT relatedVisibleGraphics()![Plane].ownedDiagramElements += create PackageWidget{modelElement := p; x :=x; y := y}; | |
return p; | |
} | |
def init_wspace(bname : String) : Collection | |
{ | |
var res := []; | |
res += _uml_cPackage(bname + '.entity', 100, 100) createClass('EntityClass') createAtt('ID') withType(umllib::Integer); | |
res += _uml_cPackage(bname + '.view', 300, 100) createClass('EntityView'); | |
res += _uml_cPackage(bname + '.presenter', 100, 300) createClass('EntityPresenter'); | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment