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 | dc27419d79eebc2c435b5eab6161239a2df61f8f (patch) | |
tree | 5f9e61ee87625c6a7afac801ca813044c4d7c9b4 /perl_checker.src | |
parent | 37f73a4ef1e26d22474bceb93ea511be4cd48685 (diff) | |
download | perl-MDK-Common-dc27419d79eebc2c435b5eab6161239a2df61f8f.tar perl-MDK-Common-dc27419d79eebc2c435b5eab6161239a2df61f8f.tar.gz perl-MDK-Common-dc27419d79eebc2c435b5eab6161239a2df61f8f.tar.bz2 perl-MDK-Common-dc27419d79eebc2c435b5eab6161239a2df61f8f.tar.xz perl-MDK-Common-dc27419d79eebc2c435b5eab6161239a2df61f8f.zip |
warn when using a regexp terminated with .* or .*$ (which is useless)
Diffstat (limited to 'perl_checker.src')
-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) ; |