diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-10-01 14:54:30 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-10-01 14:54:30 +0000 |
commit | 39108997d193862a9611d910076293eea3d2cb68 (patch) | |
tree | 8ef86a8bcde73ae66acdccd8f7e2ccb22045fc4f | |
parent | 0da64a7f8a7ef155a211d923e67b54878855ee75 (diff) | |
download | perl_checker-39108997d193862a9611d910076293eea3d2cb68.tar perl_checker-39108997d193862a9611d910076293eea3d2cb68.tar.gz perl_checker-39108997d193862a9611d910076293eea3d2cb68.tar.bz2 perl_checker-39108997d193862a9611d910076293eea3d2cb68.tar.xz perl_checker-39108997d193862a9611d910076293eea3d2cb68.zip |
also disallow map {...} %xxx
-rw-r--r-- | perl_checker.src/parser_helper.ml | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index d12a43e..5a48a10 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -794,12 +794,19 @@ let call_raw is_a_func (e, para) = Some(Call_op("qr//", pattern, pos) :: l) | _ -> None) - | "map" | "grep" -> + | "map" | "grep" | "grep_index" | "map_index" | "partition" + | "find" + | "any" | "every" + | "find_index" + | "each_index" -> (match para with | Anonymous_sub(None, Block [ List [ Call(Deref(I_func, Ident(None, "if_", _)), - [ List [ _ ; Deref(I_scalar, Ident(None, "_", _)) ] ]) ] ], _) :: _ -> + [ List [ _ ; Deref(I_scalar, Ident(None, "_", _)) ] ]) ] ], _) :: _ when f = "map" -> warn_rule "you can replace \"map { if_(..., $_) }\" with \"grep { ... }\"" + | [ Anonymous_sub _ ; Deref (I_hash, _) ] -> + warn_rule ("a hash is not a valid parameter to function " ^ f) + | Anonymous_sub _ :: _ -> () | _ -> warn_rule (sprintf "always use \"%s\" with a block (eg: %s { ... } @list)" f f)); None |