src: Updated uses of CSV library
authorLucas Bajolet <r4pass@hotmail.com>
Fri, 29 Apr 2016 20:17:27 +0000 (16:17 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 3 May 2016 03:17:46 +0000 (23:17 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

src/metrics/inheritance_metrics.nit
src/metrics/mclasses_metrics.nit
src/metrics/mendel_metrics.nit
src/metrics/metrics_base.nit
src/metrics/mmodules_metrics.nit
src/metrics/nullables_metrics.nit
src/metrics/rta_metrics.nit
src/rapid_type_analysis.nit

index 1287c0f..7638758 100644 (file)
@@ -77,11 +77,11 @@ private class InheritanceMetricsPhase
                                cmetrics.clear
                                cmetrics.collect(new HashSet[MClass].from(mod_mclasses))
                                cmetrics.to_console(1, not toolcontext.opt_nocolors.value)
-                               if csv then cmetrics.to_csv.save("{out}/{mgroup}_classes.csv")
+                               if csv then cmetrics.to_csv.write_to_file("{out}/{mgroup}_classes.csv")
                                hmetrics.clear
                                hmetrics.collect(new HashSet[MModule].from(mgroup.mmodules))
                                hmetrics.to_console(1, not toolcontext.opt_nocolors.value)
-                               if csv then hmetrics.to_csv.save("{out}/{mgroup}_inheritance.csv")
+                               if csv then hmetrics.to_csv.write_to_file("{out}/{mgroup}_inheritance.csv")
                        end
                end
                if not mclasses.is_empty then
@@ -90,11 +90,11 @@ private class InheritanceMetricsPhase
                        cmetrics.clear
                        cmetrics.collect(mclasses)
                        cmetrics.to_console(1, not toolcontext.opt_nocolors.value)
-                       if csv then cmetrics.to_csv.save("{out}/summary_classes.csv")
+                       if csv then cmetrics.to_csv.write_to_file("{out}/summary_classes.csv")
                        hmetrics.clear
                        hmetrics.collect(mmodules)
                        hmetrics.to_console(1, not toolcontext.opt_nocolors.value)
-                       if csv then hmetrics.to_csv.save("{out}/summary_inheritance.csv")
+                       if csv then hmetrics.to_csv.write_to_file("{out}/summary_inheritance.csv")
                end
        end
 end
index 89467b2..0951d10 100644 (file)
@@ -71,7 +71,7 @@ private class MClassesMetricsPhase
                                mclasses.add_all(mod_mclasses)
                                metrics.collect(new HashSet[MClass].from(mod_mclasses))
                                metrics.to_console(1, not toolcontext.opt_nocolors.value)
-                               if csv then metrics.to_csv.save("{out}/{mgroup}.csv")
+                               if csv then metrics.to_csv.write_to_file("{out}/{mgroup}.csv")
                        end
                end
                if not mclasses.is_empty then
@@ -80,7 +80,7 @@ private class MClassesMetricsPhase
                        print toolcontext.format_h2("\n ## global metrics")
                        metrics.collect(mclasses)
                        metrics.to_console(1, not toolcontext.opt_nocolors.value)
-                       if csv then metrics.to_csv.save("{out}/summary.csv")
+                       if csv then metrics.to_csv.write_to_file("{out}/summary.csv")
                end
        end
 end
index 2709ef9..1c4b6f8 100644 (file)
@@ -82,7 +82,7 @@ private class MendelMetricsPhase
                var metrics = new MetricSet
                metrics.register(cnblp, cnvi, cnvs)
                metrics.collect(mclasses)
-               if csv then metrics.to_csv.save("{out}/mendel.csv")
+               if csv then metrics.to_csv.write_to_file("{out}/mendel.csv")
 
                var threshold = cnblp.threshold
                print toolcontext.format_h4("\tlarge mclasses (threshold: {threshold})")
@@ -110,7 +110,7 @@ private class MendelMetricsPhase
 
                if csv then
                        var csvh = new CsvDocument
-                       csvh.format = new CsvFormat('"', ';', "\n")
+                       csvh.separator = ';'
                        csvh.header = ["povr", "ovr", "pext", "ext", "pspe", "spe", "prep", "rep", "eq"]
                        for mclass in mclasses do
                                var povr = mclass.is_pure_overrider(model_view).object_id
@@ -124,7 +124,7 @@ private class MendelMetricsPhase
                                var eq = mclass.is_equal(model_view).object_id
                                csvh.add_record(povr, ovr, pext, ext, pspe, spe, prep, rep, eq)
                        end
-                       csvh.save("{out}/inheritance_behaviour.csv")
+                       csvh.write_to_file("{out}/inheritance_behaviour.csv")
                end
        end
 end
index 5d83da2..a2fb201 100644 (file)
@@ -395,8 +395,7 @@ class MetricSet
        # 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")
index 335831c..dc944d8 100644 (file)
@@ -53,7 +53,7 @@ private class MModulesMetricsPhase
                                metrics.clear
                                metrics.collect(new HashSet[MModule].from(mgroup.mmodules))
                                metrics.to_console(1, not toolcontext.opt_nocolors.value)
-                               if csv then metrics.to_csv.save("{out}/{mgroup}.csv")
+                               if csv then metrics.to_csv.write_to_file("{out}/{mgroup}.csv")
                        end
                end
                if not mmodules.is_empty then
@@ -62,7 +62,7 @@ private class MModulesMetricsPhase
                        metrics.clear
                        metrics.collect(mmodules)
                        metrics.to_console(1, not toolcontext.opt_nocolors.value)
-                       if csv then metrics.to_csv.save("{out}/summary.csv")
+                       if csv then metrics.to_csv.write_to_file("{out}/summary.csv")
                end
        end
 end
index 6992ff8..abd8180 100644 (file)
@@ -61,7 +61,7 @@ private class NullablesMetricsPhase
                                mclasses.add_all(mod_mclasses)
                                metrics.collect(new HashSet[MClass].from(mod_mclasses))
                                metrics.to_console(1, not toolcontext.opt_nocolors.value)
-                               if csv then metrics.to_csv.save("{out}/{mgroup}.csv")
+                               if csv then metrics.to_csv.write_to_file("{out}/{mgroup}.csv")
                        end
                end
                if not mclasses.is_empty then
@@ -70,7 +70,7 @@ private class NullablesMetricsPhase
                        print toolcontext.format_h2("\n ## global metrics")
                        metrics.collect(mclasses)
                        metrics.to_console(1, not toolcontext.opt_nocolors.value)
-                       if csv then metrics.to_csv.save("{out}/summary.csv")
+                       if csv then metrics.to_csv.write_to_file("{out}/summary.csv")
                end
 
                compute_nullables_metrics(toolcontext.modelbuilder)
index 00f9d02..46d319a 100644 (file)
@@ -48,7 +48,7 @@ private class RTAMetricsPhase
                mmetrics.register(new MNLDD(toolcontext.modelbuilder))
                mmetrics.collect(new HashSet[MModule].from([mainmodule]))
                mmetrics.to_console(1, not toolcontext.opt_nocolors.value)
-               if csv then mmetrics.to_csv.save("{out}/{mainmodule}.csv")
+               if csv then mmetrics.to_csv.write_to_file("{out}/{mainmodule}.csv")
 
                var mtypes = new HashSet[MType]
                var analysis = new RapidTypeAnalysis(toolcontext.modelbuilder, mainmodule)
@@ -61,14 +61,14 @@ private class RTAMetricsPhase
                cmetrics.register(analysis.cnli)
                cmetrics.register(analysis.cnlc)
                cmetrics.to_console(1, not toolcontext.opt_nocolors.value)
-               if csv then cmetrics.to_csv.save("{out}/mclasses.csv")
+               if csv then cmetrics.to_csv.write_to_file("{out}/mclasses.csv")
 
                print toolcontext.format_h2("\n ## Total live instances by mtypes")
                var tmetrics = new MetricSet
                tmetrics.register(analysis.tnli)
                tmetrics.register(analysis.tnlc)
                tmetrics.to_console(1, not toolcontext.opt_nocolors.value)
-               if csv then tmetrics.to_csv.save("{out}/mtypes.csv")
+               if csv then tmetrics.to_csv.write_to_file("{out}/mtypes.csv")
 
                print toolcontext.format_h2("\n ## MType complexity")
                var gmetrics = new MetricSet
@@ -76,13 +76,13 @@ private class RTAMetricsPhase
                gmetrics.register(new TDGS)
                gmetrics.collect(mtypes)
                gmetrics.to_console(1, not toolcontext.opt_nocolors.value)
-               if csv then gmetrics.to_csv.save("{out}/complexity.csv")
+               if csv then gmetrics.to_csv.write_to_file("{out}/complexity.csv")
 
                callsite_info(analysis)
 
                # dump type and method infos
                if csv then
-                       analysis.live_types_to_csv.save("{out}/rta_types.csv")
+                       analysis.live_types_to_csv.write_to_file("{out}/rta_types.csv")
                        analysis.live_methods_to_tree.write_to_file("{out}/rta_methods.dat")
                end
        end
index 42a757b..c072314 100644 (file)
@@ -132,7 +132,7 @@ class RapidTypeAnalysis
                var types = typeset.to_a
                (new CachedAlphaComparator).sort(types)
                var res = new CsvDocument
-               res.format = new CsvFormat('"', ';', "\n")
+               res.separator = ';'
                res.header = ["Type", "Resolution", "Liveness", "Cast-liveness"]
                for t in types do
                        var reso