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

vet: remove false positive space indentation error inside block comments (#9565)

This commit is contained in:
Lukas Neubert 2021-04-02 16:26:53 +02:00 committed by GitHub
parent 1bb48c3577
commit e438b158a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View File

@ -1,2 +1,3 @@
cmd/tools/vvet/tests/indent_with_space.vv:2: error: Looks like you are using spaces for indentation.
cmd/tools/vvet/tests/indent_with_space.vv:10: error: Looks like you are using spaces for indentation.
NB: You can run `v fmt -w file.v` to fix these errors automatically

View File

@ -1,3 +1,13 @@
fn main() {
_ = 1 == 2
}
fn block_comments() {
/* tab to indent the comment
spaces before
also spaces before
same here */
/* spaces for comment indentation (ouch)
and inside too
*/
}

View File

@ -216,8 +216,8 @@ pub fn parse_vet_file(path string, table_ &ast.Table, pref &pref.Preferences) (a
}
}
}
file := p.parse()
p.vet_errors << p.scanner.vet_errors
file := p.parse()
return file, p.vet_errors
}
@ -614,9 +614,14 @@ pub fn (mut p Parser) comment() ast.Comment {
text := p.tok.lit
pos.last_line = pos.line_nr + text.count('\n')
p.next()
// p.next_with_comment()
is_multi := text.contains('\n')
// Filter out space indentation vet errors inside block comments
if p.vet_errors.len > 0 && is_multi {
p.vet_errors = p.vet_errors.filter(!(it.pos.line_nr - 1 > pos.line_nr
&& it.pos.line_nr - 1 <= pos.last_line))
}
return ast.Comment{
is_multi: text.contains('\n')
is_multi: is_multi
text: text
pos: pos
}