From 02b9bec78e8cb63fa7187ab3e141b5359c9c58cd Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 10 Nov 2015 10:02:35 -0800 Subject: [PATCH] remove extra newlines in infer output Summary: public This cleans up the output of infer. Before: $ touch empty.c $ infer -- gcc -c empty.c Starting analysis (Infer version git-436690cf022a16313dda8447121a5934529e6e5c) Analysis done No issues found $ infer -- javac Hello.java Starting analysis (Infer version git-436690cf022a16313dda8447121a5934529e6e5c) Analysis done Hello.java:4: error: NULL_DEREFERENCE object s last assigned on line 3 could be null and is dereferenced at line 4 2. int test() { 3. String s = null; 4. > return s.length(); 5. } 6. } Analyzed 2 procedures in 1 file $ After: $ infer -- gcc -c empty.c Starting analysis (Infer version git-434faa7f70f6b9498615d3ead8c12bcfec6fc553) Analyzing 0 clusters Analysis done No issues found $ infer -- javac Hello.java Starting analysis (Infer version git-434faa7f70f6b9498615d3ead8c12bcfec6fc553) Computing dependencies... 100% Analyzing 1 cluster. 100% Analysis done Found 1 issue Hello.java:4: error: NULL_DEREFERENCE object s last assigned on line 3 could be null and is dereferenced at line 4 2. int test() { 3. String s = null; 4. > return s.length(); 5. } 6. } Analyzed 2 procedures in 1 file $ Also tested with buck, gradle. Reviewed By: cristianoc Differential Revision: D2636969 fb-gh-sync-id: 52f06f0 --- infer/lib/python/inferlib/infer.py | 6 ++++-- infer/src/backend/clusterMakefile.ml | 4 ++-- infer/src/backend/inferanalyze.ml | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/infer/lib/python/inferlib/infer.py b/infer/lib/python/inferlib/infer.py index 79f069388..6a38b5d5f 100644 --- a/infer/lib/python/inferlib/infer.py +++ b/infer/lib/python/inferlib/infer.py @@ -430,9 +430,12 @@ def print_errors(csv_report, bugs_out): source_context, ) ) - if len(text_errors_list) == 0: + n_issues = len(text_errors_list) + if n_issues == 0: print_and_write(file_out, 'No issues found') else: + msg = '\nFound %s\n' % utils.get_plural('issue', n_issues) + print_and_write(file_out, msg) text_errors = '\n\n'.join(text_errors_list) print_and_write(file_out, text_errors) @@ -711,7 +714,6 @@ class Infer: clean_json(self.args, json_report) self.update_stats_with_warnings(csv_report) - print('\n') if not self.args.buck: print_errors(csv_report, bugs_out) diff --git a/infer/src/backend/clusterMakefile.ml b/infer/src/backend/clusterMakefile.ml index 4dcab01c1..14844f6fc 100644 --- a/infer/src/backend/clusterMakefile.ml +++ b/infer/src/backend/clusterMakefile.ml @@ -48,8 +48,8 @@ let pp_prolog fmt clusters = clusters; F.fprintf fmt "@.@.default: test@.@.all: test@.@."; F.fprintf fmt "test: $(OBJECTS)@."; - if !Config.show_progress_bar then F.fprintf fmt "\techo \"\\n\"@."; - F.fprintf fmt "\techo \"Analysis done\"@.@." + if !Config.show_progress_bar then F.fprintf fmt "\techo \"\"@."; + F.fprintf fmt "\techo \"Analysis done\"@." let pp_epilog fmt () = F.fprintf fmt "@.clean:@.\trm -f $(OBJECTS)@." diff --git a/infer/src/backend/inferanalyze.ml b/infer/src/backend/inferanalyze.ml index 6cf36d967..bd14d9b1a 100644 --- a/infer/src/backend/inferanalyze.ml +++ b/infer/src/backend/inferanalyze.ml @@ -506,7 +506,7 @@ let compute_clusters exe_env files_changed : Cluster.t list = end end in IList.iter do_node nodes; - L.log_progress_simple "\n"; + if IList.length nodes > 0 then L.log_progress_simple "\n"; if not !Config.intraprocedural then IList.iter do_edge edges; if !save_file_dependency then Cg.save_call_graph_dotty (Some (DB.filename_from_string "file_dependency.dot")) Specs.get_specs file_cg; @@ -537,7 +537,9 @@ let compute_clusters exe_env files_changed : Cluster.t list = L.err "@.Combined clusters with max size %d@." max_cluster_size; Cluster.print_clusters_stats clusters'; let number_of_clusters = IList.length clusters' in - L.log_progress_simple ("\nAnalyzing "^(string_of_int number_of_clusters)^" clusters"); + let plural_of_cluster = if number_of_clusters != 1 then "s" else "" in + L.log_progress_simple + (Printf.sprintf "Analyzing %d cluster%s" number_of_clusters plural_of_cluster); ClusterMakefile.create_cluster_makefile_and_exit clusters' file_cg !makefile_cmdline false end; let clusters' =