vet: turn warnings into errors with -W flag (#9575)
parent
31f8d5542c
commit
646d46b4dc
|
@ -77,7 +77,7 @@ fn main() {
|
||||||
if vfmt_err_count > 0 {
|
if vfmt_err_count > 0 {
|
||||||
eprintln('NB: You can run `v fmt -w file.v` to fix these errors automatically')
|
eprintln('NB: You can run `v fmt -w file.v` to fix these errors automatically')
|
||||||
}
|
}
|
||||||
if vt.errors.len > 0 || (vt.opt.is_werror && vt.warns.len > 0) {
|
if vt.errors.len > 0 {
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,13 +236,19 @@ fn (mut vt Vet) warn(msg string, line int, fix vet.FixKind) {
|
||||||
pos := token.Position{
|
pos := token.Position{
|
||||||
line_nr: line + 1
|
line_nr: line + 1
|
||||||
}
|
}
|
||||||
vt.warns << vet.Error{
|
mut w := vet.Error{
|
||||||
message: msg
|
message: msg
|
||||||
file_path: vt.file
|
file_path: vt.file
|
||||||
pos: pos
|
pos: pos
|
||||||
kind: .warning
|
kind: .warning
|
||||||
fix: fix
|
fix: fix
|
||||||
}
|
}
|
||||||
|
if vt.opt.is_werror {
|
||||||
|
w.kind = .error
|
||||||
|
vt.errors << w
|
||||||
|
} else {
|
||||||
|
vt.warns << w
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_use_color() bool {
|
fn should_use_color() bool {
|
||||||
|
|
|
@ -16,12 +16,13 @@ pub enum FixKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Error {
|
pub struct Error {
|
||||||
|
pub mut:
|
||||||
|
kind ErrorKind [required]
|
||||||
pub:
|
pub:
|
||||||
// General message
|
// General message
|
||||||
message string [required]
|
message string [required]
|
||||||
details string // Details about how to resolve or fix the situation
|
details string // Details about how to resolve or fix the situation
|
||||||
file_path string // file where the error have origin
|
file_path string // file where the error have origin
|
||||||
pos token.Position // position in the file
|
pos token.Position // position in the file
|
||||||
kind ErrorKind [required]
|
|
||||||
fix FixKind [required]
|
fix FixKind [required]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue