mclasses.add_all(mod_mclasses)
cmetrics.collect(new HashSet[MClass].from(mod_mclasses), mainmodule)
for name, metric in cmetrics.metrics do
- print toolcontext.format_h4("\t{name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
+ if metric isa IntMetric then
+ print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_p("\t avg: {metric.avg}")
+ var max = metric.max
+ print toolcontext.format_p("\t max: {max.first} ({max.second})")
+ var min = metric.min
+ print toolcontext.format_p("\t min: {min.first} ({min.second})")
+ end
end
hmetrics.collect(new HashSet[MModule].from(mgroup.mmodules), mainmodule)
for name, metric in hmetrics.metrics do
- print toolcontext.format_h4("\t{name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
+ if metric isa FloatMetric then
+ print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_p("\t avg: {metric.avg}")
+ var max = metric.max
+ print toolcontext.format_p("\t max: {max.first} ({max.second})")
+ var min = metric.min
+ print toolcontext.format_p("\t min: {min.first} ({min.second})")
+ end
end
end
end
print toolcontext.format_h2("\n ## global metrics")
cmetrics.collect(mclasses, mainmodule)
for name, metric in cmetrics.metrics do
- print toolcontext.format_h4("\t{name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
+ if metric isa IntMetric then
+ print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_p("\t avg: {metric.avg}")
+ var max = metric.max
+ print toolcontext.format_p("\t max: {max.first} ({max.second})")
+ var min = metric.min
+ print toolcontext.format_p("\t min: {min.first} ({min.second})")
+ end
end
hmetrics.collect(mmodules, mainmodule)
for name, metric in hmetrics.metrics do
- print toolcontext.format_h4("\t{name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
+ if metric isa FloatMetric then
+ print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_p("\t avg: {metric.avg}")
+ var max = metric.max
+ print toolcontext.format_p("\t max: {max.first} ({max.second})")
+ var min = metric.min
+ print toolcontext.format_p("\t min: {min.first} ({min.second})")
+ end
end
end
end
# Metric Set used to collect data about inheritance in each module
class InheritanceMetricSet
super MetricSet
- redef type METRIC: InheritanceMetric
+ redef type METRIC: MModuleMetric
fun collect(mmodules: Set[MModule], mainmodule: MModule) do
clear
for metric in metrics.values do
end
end
-# An abstract metric used to collect data about inheritance usage
-#
-# The metric is based on a module
-abstract class InheritanceMetric
- super FloatMetric[MModule]
- fun collect(mmodule: MModule, mainmodule: MModule) is abstract
-end
-
# Module metric: proportion of MClasses Defined Using Inheritance
#
# Count MClasses that have another parents than Object
class MDUI
- super InheritanceMetric
+ super MModuleMetric
+ super FloatMetric
redef fun name do return "mdui"
redef fun desc do return "proportion of mclass defined using inheritance (has other parent than Object)"
#
# Count classes that have another parents than Object
class MDUIC
- super InheritanceMetric
+ super MModuleMetric
+ super FloatMetric
redef fun name do return "mduic"
redef fun desc do return "proportion of class_kind defined using inheritance"
#
# Count interface that have another parents than Object
class MDUII
- super InheritanceMetric
+ super MModuleMetric
+ super FloatMetric
redef fun name do return "mduii"
redef fun desc do return "proportion of interface_kind defined using inheritance"
#
# Count classes that have at least a child
class MIF
- super InheritanceMetric
+ super MModuleMetric
+ super FloatMetric
redef fun name do return "mif"
redef fun desc do return "proportion of mclass inherited from"
#
# Count classes that have at least a child
class MIFC
- super InheritanceMetric
+ super MModuleMetric
+ super FloatMetric
redef fun name do return "mifc"
redef fun desc do return "proportion of class_kind inherited from"
#
# Count interfaces that have at least a child
class MIFI
- super InheritanceMetric
+ super MModuleMetric
+ super FloatMetric
redef fun name do return "mifi"
redef fun desc do return "proportion of interface_kind inherited from"
# Count only absrtract, concrete and extern classes
class CNOAC
super MClassMetric
+ super IntMetric
redef fun name do return "cnoac"
redef fun desc do return "number of class_kind ancestor"
# Count only absrtract, concrete and extern classes
class CNOPC
super MClassMetric
+ super IntMetric
redef fun name do return "cnopc"
redef fun desc do return "number of class_kind parent"
# Count only absrtract, concrete and extern classes
class CNOCC
super MClassMetric
+ super IntMetric
redef fun name do return "cnocc"
redef fun desc do return "number of class_kind children"
# Count only absrtract, concrete and extern classes
class CNODC
super MClassMetric
+ super IntMetric
redef fun name do return "cnodc"
redef fun desc do return "number of class_kind descendants"
# Count only interfaces
class CNOAI
super MClassMetric
+ super IntMetric
redef fun name do return "cnoai"
redef fun desc do return "number of interface_kind ancestor"
# Count only interfaces
class CNOPI
super MClassMetric
+ super IntMetric
redef fun name do return "cnopi"
redef fun desc do return "number of interface_kind parent"
# Count only interfaces
class CNOCI
super MClassMetric
+ super IntMetric
redef fun name do return "cnoci"
redef fun desc do return "number of interface_kind children"
# Count only interfaces
class CNODI
super MClassMetric
+ super IntMetric
redef fun name do return "cnodi"
redef fun desc do return "number of interface_kind descendants"
# Following the longest path composed only of extends edges from self to Object
class CDITC
super MClassMetric
+ super IntMetric
redef fun name do return "cditc"
redef fun desc do return "depth in class tree following only class, abstract, extern kind"
# Following the longest path composed only of implements edges from self to Object
class CDITI
super MClassMetric
+ super IntMetric
redef fun name do return "cditi"
redef fun desc do return "depth in class tree following only interface_kind"