core :: Sys :: compute_nullables_metrics
# Visit the AST and print metrics about the usage of send on nullable reciever.
fun compute_nullables_metrics(modelbuilder: ModelBuilder)
do
print "--- Sends on Nullable Receiver ---"
var total_sends = 0
var nullable_sends = 0
var nullable_eq_sends = 0
var buggy_sends = 0
# Visit all the source code to collect data
for nmodule in modelbuilder.nmodules do
for nclassdef in nmodule.n_classdefs do
var visitor = new NullableSends(nclassdef)
visitor.enter_visit(nclassdef)
total_sends += visitor.total_sends
nullable_sends += visitor.nullable_sends
nullable_eq_sends += visitor.nullable_eq_sends
buggy_sends += visitor.buggy_sends
end
end
print "Total number of sends: {total_sends}"
print "Number of sends on a unsafe nullable receiver: {nullable_sends} ({div(nullable_sends*100,total_sends)}%)"
print "Number of sends on a safe nullable receiver: {nullable_eq_sends} ({div(nullable_eq_sends*100,total_sends)}%)"
print "Number of buggy sends (cannot determine the type of the receiver): {buggy_sends} ({div(buggy_sends*100,total_sends)}%)"
end
src/metrics/nullables_metrics.nit:145,1--169,3