1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v vet: give an error for trailing whitespace (#9574)

This commit is contained in:
Lukas Neubert
2021-04-09 12:22:14 +02:00
committed by GitHub
parent ddb2e72301
commit 46e7e27ba3
12 changed files with 67 additions and 20 deletions

View File

@ -54,7 +54,7 @@ fn main() {
if '-h' in args || '--help' in args {
println("Usage:
test_os_process [-v] [-h] [-target stderr/stdout/both/alternate] [-exitcode 0] [-timeout_ms 200] [-period_ms 50]
Prints lines periodically (-period_ms), to stdout/stderr (-target).
Prints lines periodically (-period_ms), to stdout/stderr (-target).
After a while (-timeout_ms), exit with (-exitcode).
This program is useful for platform independent testing
of child process/standart input/output control.

View File

@ -5,7 +5,9 @@ import testing
import v.util
const (
vet_known_failing_exceptions = []string{}
vet_known_failing_exceptions = [
'vlib/v/gen/js/js.v' /* trailing space */,
]
vet_folders = [
'vlib/sqlite',
'vlib/v',
@ -115,7 +117,8 @@ fn tsession(vargs string, tool_source string, tool_cmd string, tool_args string,
}
fn v_test_vetting(vargs string) {
vet_session := tsession(vargs, 'vvet', 'v vet', 'vet', vet_folders, vet_known_failing_exceptions)
expanded_vet_list := util.find_all_v_files(vet_folders) or { return }
vet_session := tsession(vargs, 'vvet', 'v vet', 'vet', expanded_vet_list, vet_known_failing_exceptions)
fmt_cmd, fmt_args := if is_fix { 'v fmt -w', 'fmt -w' } else { 'v fmt -verify', 'fmt -verify' }
expanded_vfmt_list := util.find_all_v_files(vfmt_verify_list) or { return }
verify_session := tsession(vargs, 'vfmt.v', fmt_cmd, fmt_args, expanded_vfmt_list,

View File

@ -0,0 +1,7 @@
cmd/tools/vvet/tests/trailing_space.vv:5: error: Looks like you have trailing whitespace.
cmd/tools/vvet/tests/trailing_space.vv:6: error: Looks like you have trailing whitespace.
cmd/tools/vvet/tests/trailing_space.vv:7: error: Looks like you have trailing whitespace.
cmd/tools/vvet/tests/trailing_space.vv:8: error: Looks like you have trailing whitespace.
cmd/tools/vvet/tests/trailing_space.vv:9: error: Looks like you have trailing whitespace.
cmd/tools/vvet/tests/trailing_space.vv:13: error: Looks like you have trailing whitespace.
cmd/tools/vvet/tests/trailing_space.vv:15: error: Looks like you have trailing whitespace.

View File

@ -0,0 +1,16 @@
// NB: This file has and *should* have trailing spaces.
// When making changes, please ensure they are not removed.
fn after_comments() {
// spaces after line comments give errors
/*
in block comments
too
*/
}
fn main() {
var := 'error about the spaces right there'
no_err := "inside multi line strings it's fine.
but not after"
}

View File

@ -229,6 +229,7 @@ fn (mut vt Vet) error(msg string, line int, fix vet.FixKind) {
pos: pos
kind: .error
fix: fix
typ: .default
}
}
@ -242,6 +243,7 @@ fn (mut vt Vet) warn(msg string, line int, fix vet.FixKind) {
pos: pos
kind: .warning
fix: fix
typ: .default
}
if vt.opt.is_werror {
w.kind = .error