diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-04-10 11:06:16 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-04-10 11:06:16 +0000 |
commit | 9a4b72a011db84ce1997977bebd75030226e7edf (patch) | |
tree | 61071644d18b6f225ffeac4c363b38224ed8cb7c | |
parent | a01b7c5fe23248bc378b4825f3de1c903720e52a (diff) | |
download | perl_checker-9a4b72a011db84ce1997977bebd75030226e7edf.tar perl_checker-9a4b72a011db84ce1997977bebd75030226e7edf.tar.gz perl_checker-9a4b72a011db84ce1997977bebd75030226e7edf.tar.bz2 perl_checker-9a4b72a011db84ce1997977bebd75030226e7edf.tar.xz perl_checker-9a4b72a011db84ce1997977bebd75030226e7edf.zip |
warn when using a regexp terminated with .* or .*$ (which is useless)
-rw-r--r-- | perl_checker.src/parser_helper.ml | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index d5869ec..fc84b93 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -778,7 +778,15 @@ let to_String parse strict (l, (_, pos)) = String(l', raw_pos2pos pos) let from_PATTERN parse ((s, opts), (_, pos)) = - [ String(parse_interpolated parse s, raw_pos2pos pos) ; + let re = parse_interpolated parse s in + (match List.rev re with + | (s, List []) :: _ -> + if str_ends_with s ".*" then + warn_rule (sprintf "you can remove \"%s\" at the end of your regexp" ".*") + else if str_ends_with s ".*$" then + warn_rule (sprintf "you can remove \"%s\" at the end of your regexp" ".*$") + | _ -> ()); + [ String(re, raw_pos2pos pos) ; Raw_string(opts, raw_pos2pos pos) ] let from_PATTERN_SUBST parse ((s1, s2, opts), (_, pos)) = [ String(parse_interpolated parse s1, raw_pos2pos pos) ; |