print toolcontext.format_h1("\n# Inheritance metrics")
- var hmetrics = new InheritanceMetricSet
+ var hmetrics = new MetricSet
hmetrics.register(new MDUI(mainmodule))
hmetrics.register(new MDUIC(mainmodule))
hmetrics.register(new MDUII(mainmodule))
hmetrics.register(new MIFC(mainmodule))
hmetrics.register(new MIFI(mainmodule))
- var cmetrics = new MClassMetricSet
+ var cmetrics = new MetricSet
cmetrics.register(new CNOAC(mainmodule))
cmetrics.register(new CNOPC(mainmodule))
cmetrics.register(new CNOCC(mainmodule))
if mod_mclasses.is_empty then continue
mmodules.add_all(mgroup.mmodules)
mclasses.add_all(mod_mclasses)
- cmetrics.collect(new HashSet[MClass].from(mod_mclasses), mainmodule)
- for name, metric in cmetrics.metrics do
+ cmetrics.collect(new HashSet[MClass].from(mod_mclasses))
+ for metric in cmetrics.metrics do
if metric isa IntMetric then
- print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_h4("\t{metric.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})")
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
+ hmetrics.collect(new HashSet[MModule].from(mgroup.mmodules))
+ for metric in hmetrics.metrics do
if metric isa FloatMetric then
- print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_h4("\t{metric.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})")
if not mclasses.is_empty then
# Global metrics
print toolcontext.format_h2("\n ## global metrics")
- cmetrics.collect(mclasses, mainmodule)
- for name, metric in cmetrics.metrics do
+ cmetrics.clear
+ cmetrics.collect(mclasses)
+ for metric in cmetrics.metrics do
if metric isa IntMetric then
- print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_h4("\t{metric.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})")
print toolcontext.format_p("\t min: {min.first} ({min.second})")
end
end
- hmetrics.collect(mmodules, mainmodule)
- for name, metric in hmetrics.metrics do
+ hmetrics.clear
+ hmetrics.collect(mmodules)
+ for metric in hmetrics.metrics do
if metric isa FloatMetric then
- print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_h4("\t{metric.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})")
end
end
-# Metric Set used to collect data about inheritance in each module
-class InheritanceMetricSet
- super MetricSet
- redef type METRIC: MModuleMetric
- fun collect(mmodules: Set[MModule], mainmodule: MModule) do
- clear
- for metric in metrics.values do
- metric.collect(mmodules)
- end
- end
-end
-
# Module metric: proportion of MClasses Defined Using Inheritance
#
# Count MClasses that have another parents than Object
print toolcontext.format_h1("\n# MClasses metrics")
- var metrics = new MClassMetricSet
+ var metrics = new MetricSet
var min_vis = private_visibility
metrics.register(new CNOA(mainmodule))
metrics.register(new CNOP(mainmodule))
for mmodule in mgroup.mmodules do mod_mclasses.add_all(mmodule.intro_mclasses)
if mod_mclasses.is_empty then continue
mclasses.add_all(mod_mclasses)
- metrics.collect(new HashSet[MClass].from(mod_mclasses), mainmodule)
- for name, metric in metrics.metrics do
+ metrics.collect(new HashSet[MClass].from(mod_mclasses))
+ for metric in metrics.metrics do
if metric isa IntMetric then
- print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_h4("\t{metric.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})")
if not mclasses.is_empty then
# Global metrics
print toolcontext.format_h2("\n ## global metrics")
-
- metrics.collect(mclasses, mainmodule)
- for name, metric in metrics.metrics do
+ metrics.collect(mclasses)
+ for metric in metrics.metrics do
if metric isa IntMetric then
- print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_h4("\t{metric.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})")
end
end
-# An MetricSet for MClasses metrics
-class MClassMetricSet
- super MetricSet
- redef type METRIC: MClassMetric
-
- # Collect all the metrics on the set of MClasses
- fun collect(mclasses: Set[MClass], mainmodule: MModule) do
- clear
- for metric in metrics.values do
- metric.collect(mclasses)
- end
- end
-end
-
# A metric about MClass
interface MClassMetric
super Metric
#
# It purpose is to be extended with a metric collect service
class MetricSet
- type METRIC: Metric
+ type ELM: Object
# Metrics to compute
- var metrics: Map[String, METRIC] = new HashMap[String, METRIC]
+ var metrics: Set[Metric] = new HashSet[Metric]
# Add a metric to the set
- fun register(metrics: METRIC...) do for metric in metrics do self.metrics[metric.name] = metric
+ fun register(metrics: Metric...) do for metric in metrics do self.metrics.add(metric)
# Clear all results for all metrics
- fun clear do for metric in metrics.values do metric.clear
+ fun clear do for metric in metrics do metric.clear
+
+ # Collect all metrics for this set of class
+ fun collect(elements: Set[ELM]) do
+ for metric in metrics do metric.collect(elements)
+ end
+
end
print toolcontext.format_h1("\n# MModules metrics")
- var metrics = new MModuleMetricSet
+ var metrics = new MetricSet
metrics.register(new MNOA, new MNOP, new MNOC, new MNOD, new MDIT)
metrics.register(new MNBI, new MNBR, new MNBCC, new MNBAC, new MNBIC)
print toolcontext.format_h3(" `- group {mgroup.full_name}")
mmodules.add_all(mgroup.mmodules)
- metrics.collect(new HashSet[MModule].from(mgroup.mmodules), mainmodule)
- for name, metric in metrics.metrics do
+ metrics.collect(new HashSet[MModule].from(mgroup.mmodules))
+ for metric in metrics.metrics do
if metric isa IntMetric then
- print toolcontext.format_h4("\t{name}: {metric.desc}")
+ print toolcontext.format_h4("\t{metric.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})")
if not mmodules.is_empty then
# Global metrics
print toolcontext.format_h2("\n ## global metrics")
-
- metrics.collect(mmodules, mainmodule)
- for name, metric in metrics.metrics do
+ metrics.clear
+ metrics.collect(mmodules)
+ for metric in metrics.metrics do
if metric isa IntMetric then
- print toolcontext.format_h4( "\t{name}: {metric.desc}")
+ print toolcontext.format_h4( "\t{metric.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})")
end
end
-# A MetricSet for metrics about MModules
-class MModuleMetricSet
- super MetricSet
- redef type METRIC: MModuleMetric
-
- # Collect all the metrics on the set of MModules
- fun collect(mmodules: Set[MModule], mainmodule: MModule) do
- clear
- for metric in metrics.values do
- metric.collect(mmodules)
- end
- end
-end
-
-# An abstract Metric on MModules
-abstract class MModuleMetric
+# A metric about MModule
+interface MModuleMetric
super Metric
redef type ELM: MModule
end