From 1345eac57089db6e9608ed6b144ca077ffda847b Mon Sep 17 00:00:00 2001 From: Elsie Date: Sun, 24 Nov 2024 05:21:16 -0500 Subject: [PATCH] vet: make `v vet` produce a nicer note, including the offending files, instead of `file.v` (#22957) --- cmd/tools/vvet/tests/array_init_one_val.out | 2 +- cmd/tools/vvet/tests/indent_with_space.out | 2 +- cmd/tools/vvet/vvet.v | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/tools/vvet/tests/array_init_one_val.out b/cmd/tools/vvet/tests/array_init_one_val.out index 25d3f315f..46b101dae 100644 --- a/cmd/tools/vvet/tests/array_init_one_val.out +++ b/cmd/tools/vvet/tests/array_init_one_val.out @@ -1,3 +1,3 @@ cmd/tools/vvet/tests/array_init_one_val.vv:2: error: Use `1 == 1` instead of `1 in [1]` cmd/tools/vvet/tests/array_init_one_val.vv:6: error: Use `'foo' != bar` instead of `'foo' !in [bar]` -Note: You can run `v fmt -w file.v` to fix these errors automatically +Note: You can run `v fmt -w cmd/tools/vvet/tests/array_init_one_val.vv` to fix these errors automatically diff --git a/cmd/tools/vvet/tests/indent_with_space.out b/cmd/tools/vvet/tests/indent_with_space.out index 15a1a1526..65c9f5882 100644 --- a/cmd/tools/vvet/tests/indent_with_space.out +++ b/cmd/tools/vvet/tests/indent_with_space.out @@ -3,4 +3,4 @@ cmd/tools/vvet/tests/indent_with_space.vv:10: error: Looks like you are using sp cmd/tools/vvet/tests/indent_with_space.vv:17: error: Looks like you are using spaces for indentation. cmd/tools/vvet/tests/indent_with_space.vv:20: error: Looks like you are using spaces for indentation. cmd/tools/vvet/tests/indent_with_space.vv:22: error: Looks like you are using spaces for indentation. -Note: You can run `v fmt -w file.v` to fix these errors automatically +Note: You can run `v fmt -w cmd/tools/vvet/tests/indent_with_space.vv` to fix these errors automatically \ No newline at end of file diff --git a/cmd/tools/vvet/vvet.v b/cmd/tools/vvet/vvet.v index 2cd65a068..46def5d7b 100644 --- a/cmd/tools/vvet/vvet.v +++ b/cmd/tools/vvet/vvet.v @@ -9,6 +9,7 @@ import v.parser import v.ast import v.help import term +import arrays struct Vet { mut: @@ -94,7 +95,8 @@ fn main() { eprintln(vt.e2string(err)) } if vfmt_err_count > 0 { - eprintln('Note: You can run `v fmt -w file.v` to fix these errors automatically') + filtered_out := arrays.distinct(vt.errors.map(it.file_path)) + eprintln('Note: You can run `v fmt -w ${filtered_out.join(' ')}` to fix these errors automatically') } if vt.errors.len > 0 { exit(1) -- 2.39.5