summaryrefslogtreecommitdiffstats
path: root/perl_checker.src/parser_helper.ml
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-04-01 15:47:31 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-04-01 15:47:31 +0000
commit9cbab8aa086051a00a05a8fdfaf58a0e7fe0c418 (patch)
tree310f5a6b45cb513624b0270438cb382fa95e33b8 /perl_checker.src/parser_helper.ml
parente8d753659e1cf367aefc22c34babef895ea6c529 (diff)
downloadperl-MDK-Common-9cbab8aa086051a00a05a8fdfaf58a0e7fe0c418.tar
perl-MDK-Common-9cbab8aa086051a00a05a8fdfaf58a0e7fe0c418.tar.gz
perl-MDK-Common-9cbab8aa086051a00a05a8fdfaf58a0e7fe0c418.tar.bz2
perl-MDK-Common-9cbab8aa086051a00a05a8fdfaf58a0e7fe0c418.tar.xz
perl-MDK-Common-9cbab8aa086051a00a05a8fdfaf58a0e7fe0c418.zip
- $foo =~ /^dhcp$/ is better written $foo eq 'dhcp'
- warn "grep(&f, ...)", use "grep { f } ..." instead
Diffstat (limited to 'perl_checker.src/parser_helper.ml')
-rw-r--r--perl_checker.src/parser_helper.ml13
1 files changed, 11 insertions, 2 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index 1f2a1c3..daaad87 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -422,6 +422,15 @@ let check_block_ref (l, (_, (_, end_)) as ter_lines) (_, (space, _) as ter_BRACK
let check_my_our_paren (((comma_closed, _), _), _) =
if not comma_closed then die_rule "syntax error"
+let check_simple_pattern = function
+ | [ String([ st, List [] ], _); Raw_string("", _) ] ->
+ if String.length st > 2 &&
+ st.[0] = '^' && st.[String.length st - 1] = '$' then
+ let st = skip_n_char_ 1 1 st in
+ if string_forall_with char_is_alphanumerical_ 0 st then
+ warn_rule (sprintf "\"... =~ /^%s$/\" is better written \"... eq %s\"" st st)
+ | _ -> ()
+
let rec only_one (l, (spaces, pos)) =
match l with
| [List l'] -> only_one (l', (spaces, pos))
@@ -677,10 +686,10 @@ let call_func is_a_func (e, para) =
Some(Call_op("qr//", pattern, pos) :: l)
| _ -> None)
- | "map" ->
+ | "map" | "grep" ->
(match para with
| Anonymous_sub _ :: _ -> ()
- | _ -> warn_rule "always use \"map\" with a block (eg: map { ... } @list)");
+ | _ -> warn_rule (sprintf "always use \"%s\" with a block (eg: map { ... } @list)" f));
None
| _ -> None