Skip to content

Commit

Permalink
add option -r -F
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jan 8, 2025
1 parent c2fbc37 commit c6360a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/tools/vvet/analysis.v
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ fn (mut vt Vet) vet_repeated_code() {
}

fn (mut vt Vet) vet_code_analysis() {
vt.vet_repeated_code()
if vt.opt.repeated_code {
vt.vet_repeated_code()
}
}
8 changes: 7 additions & 1 deletion cmd/tools/vvet/vvet.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ struct Options {
show_warnings bool
use_color bool
doc_private_fns_too bool
fn_sizing bool
repeated_code bool
mut:
is_vfmt_off bool
}
Expand All @@ -47,6 +49,8 @@ fn main() {
doc_private_fns_too: '-p' in vet_options
use_color: '-color' in vet_options
|| (term_colors && '-nocolor' !in vet_options)
repeated_code: '-r' in vet_options
fn_sizing: '-F' in vet_options
}
}
mut paths := cmdline.only_non_options(vet_options)
Expand Down Expand Up @@ -285,7 +289,9 @@ fn (mut vt Vet) stmt(stmt ast.Stmt) {
}
ast.FnDecl {
vt.stmts(stmt.stmts)
vt.long_or_empty_fns(stmt)
if vt.opt.fn_sizing {
vt.long_or_empty_fns(stmt)
}
}
else {}
}
Expand Down
4 changes: 4 additions & 0 deletions vlib/v/help/common/vet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ Options:

-v, -verbose Enable verbose logging.

-F Report empty and long function declaration (>300 lines).

-p Report private functions with missing documentation too
(by default, only the `pub fn` functions will be reported).

-r Report repeated piece of code (e.g. var[0], call()).

0 comments on commit c6360a5

Please sign in to comment.