toolcontext: `process_options` require arguments.
[nit.git] / src / metrics / nullables_metrics.nit
index ff85b2a..d788260 100644 (file)
@@ -20,6 +20,20 @@ module nullables_metrics
 import modelbuilder
 private import typing
 private import metrics_base
+import frontend
+
+redef class ToolContext
+       var nullables_metrics_phase = new NullablesMetricsPhase(self, null)
+end
+
+private class NullablesMetricsPhase
+       super Phase
+       redef fun process_mainmodule(mainmodule)
+       do
+               if not toolcontext.opt_nullables.value and not toolcontext.opt_all.value then return
+               compute_nullables_metrics(toolcontext.modelbuilder)
+       end
+end
 
 private class NullableSends
        super Visitor
@@ -30,7 +44,7 @@ private class NullableSends
        var nullable_sends: Int = 0
        var buggy_sends: Int = 0
 
-       # Get a new visitor on a classef to add type count in `typecount'.
+       # Get a new visitor on a classef to add type count in `typecount`.
        init(modelbuilder: ModelBuilder, nclassdef: AClassdef)
        do
                self.modelbuilder = modelbuilder
@@ -62,7 +76,7 @@ end
 # 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 Reciever ---"
+       print "--- Sends on Nullable Receiver ---"
        var total_sends = 0
        var nullable_sends = 0
        var buggy_sends = 0