Skip to content

Commit

Permalink
Add percent of native and no augmented class into components in metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
labordep committed Oct 28, 2023
1 parent e2eb9e0 commit 4fa7e77
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Molecule-IDE-Incubator/MolCodeMetricsCmdCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ MolCodeMetricsCmdCommand >> execute [
MolCodeMetricsCmdCommand >> metricsForSelectedPackagesClasses: aStream [

"Number of classes and traits"
| nbClasses nbTraits nbComponents nbTypes nbServicesInterface nbEventsInterface nbParametersInterface nbInstanceMethods nbClasseMethods |
| nbClasses nbTraits nbComponents nbTypes nbServicesInterface nbEventsInterface nbParametersInterface nbInstanceMethods nbClasseMethods nbOfNativeComponents nbOfAugmentedClassAsComponents |
nbClasses := (self selectedPackagesClasses select:[ :c | c isClass ]) size.
nbTraits := (self selectedPackagesClasses select:[ :c | c isTrait ]) size.

Expand All @@ -68,6 +68,8 @@ MolCodeMetricsCmdCommand >> metricsForSelectedPackagesClasses: aStream [

"Number of components class"
nbComponents := self selectedPackagesComponentClasses size.
nbOfNativeComponents := (self selectedPackagesComponentClasses select: [ :comp | comp allSuperclasses includes: MolAbstractComponentImpl ]) size.
nbOfAugmentedClassAsComponents := (self selectedPackagesComponentClasses select: [ :comp | (comp allSuperclasses includes: MolAbstractComponentImpl) not ]) size.

"Number of Component Types and contract interfaces"
nbTypes := (self selectedPackagesClasses select:[ :c | c isTrait and:[ c isComponentType ] ]) size.
Expand All @@ -77,7 +79,9 @@ MolCodeMetricsCmdCommand >> metricsForSelectedPackagesClasses: aStream [

aStream nextPutAll: '### Global metrics'; cr.
aStream nextPutAll: ((nbComponents * 100 / nbClasses) rounded) asString, '% of classes are components'; cr.
nbTraits > 0 ifTrue:[aStream nextPutAll: (((nbTypes + nbServicesInterface + nbEventsInterface + nbParametersInterface) * 100 / nbTraits) rounded) asString, '% of traits are component contract'; cr].
nbTraits > 0 ifTrue:[
aStream nextPutAll: (((nbTypes + nbServicesInterface + nbEventsInterface + nbParametersInterface) * 100 / nbTraits) rounded) asString, '% of traits are component contract'; cr
].
aStream nextPutAll: 'Nb of classes: ', nbClasses asString; cr.
aStream nextPutAll: 'Nb of traits: ', nbTraits asString; cr.
aStream nextPutAll: 'Total: ', (nbClasses + nbTraits) asString; cr.
Expand All @@ -89,6 +93,13 @@ MolCodeMetricsCmdCommand >> metricsForSelectedPackagesClasses: aStream [

aStream nextPutAll: '### Molecule entities'; cr.
aStream nextPutAll: 'Nb of components: ', nbComponents asString; cr.

nbComponents > 0 ifTrue:[
aStream nextPutAll: 'Nb of native components: ', nbOfNativeComponents asString, ' (', (nbOfNativeComponents * 100 / nbComponents) rounded asString , '%)'; cr.
aStream nextPutAll: 'Nb of augmented classes into components: ', nbOfAugmentedClassAsComponents asString, ' (', (nbOfAugmentedClassAsComponents * 100 / nbComponents) rounded asString , '%)'; cr.
].
aStream cr.

aStream nextPutAll: 'Nb of types interfaces: ', nbTypes asString; cr.
aStream nextPutAll: 'Nb of services interfaces: ', nbServicesInterface asString; cr.
aStream nextPutAll: 'Nb of events interfaces: ', nbEventsInterface asString; cr.
Expand Down

0 comments on commit 4fa7e77

Please sign in to comment.