var opt_tables = new OptionBool("Compute tables metrics", "--tables")
# --rta
var opt_rta = new OptionBool("Compute RTA metrics", "--rta")
+ # --readme
+ var opt_readme = new OptionBool("Compute ReadMe metrics", "--readme")
# --generate-csv
- var opt_csv = new OptionBool("Export metrics in CSV format", "--csv")
+ var opt_csv = new OptionBool("Also export metrics in CSV format", "--csv")
# --generate_hyperdoc
var opt_generate_hyperdoc = new OptionBool("Generate Hyperdoc", "--generate_hyperdoc")
# --poset
self.option_context.add_option(opt_static_types)
self.option_context.add_option(opt_tables)
self.option_context.add_option(opt_rta)
+ self.option_context.add_option(opt_readme)
self.option_context.add_option(opt_csv)
self.option_context.add_option(opt_generate_hyperdoc)
self.option_context.add_option(opt_poset)
end
-redef class MClass
- # is the class imported from standard lib?
- fun is_standard: Bool do
- return self.intro_mmodule.mgroup.mproject.name == "standard"
- end
-end
-
-redef class MModule
- # is the module imported from standard lib?
- fun is_standard: Bool do
- return self.mgroup.mproject.name == "standard"
- end
-end
-
# A Metric is used to collect data about things
#
# The concept is reified here for a better organization and documentation
fun values: RES is abstract
# Collect metric values on elements
- fun collect(elements: Set[ELM]) is abstract
+ fun collect(elements: Collection[ELM]) is abstract
# The value calculated for the element
fun [](element: ELM): VAL do return values[element]
class IntMetric
super Metric
- redef type VAL: Int
+ redef type VAL: Int is fixed
redef type RES: Counter[ELM]
# `IntMetric` uses a Counter to store values in intern.
redef fun sum do
var sum = 0.0
- for v in values.values do sum += v
+ for v in values.values do
+ if v.is_nan then continue
+ sum += v
+ end
return sum
end
redef fun std_dev do
var sum = 0.0
for value in values.values do
+ if value.is_nan then continue
sum += (value - avg).pow(2.to_f)
end
return (sum / values.length.to_f).sqrt
# Export the metric set in CSV format
fun to_csv: CsvDocument do
var csv = new CsvDocument
-
- csv.format = new CsvFormat('"', ';', "\n")
+ csv.separator = ';'
# set csv headers
csv.header.add("entry")