diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-11-17 17:06:52 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-11-17 17:06:52 +0000 |
commit | c0e7b9c7d3dd295f2d432c096508fcffbcbbc837 (patch) | |
tree | 122a51746bc0a80a3f8c59079b6bc601a65a7bd5 /perl_checker.src/parser_helper.ml | |
parent | 87bc1a8e7cb91e78fcaec2a6f8a554500a4dc6c6 (diff) | |
download | perl_checker-c0e7b9c7d3dd295f2d432c096508fcffbcbbc837.tar perl_checker-c0e7b9c7d3dd295f2d432c096508fcffbcbbc837.tar.gz perl_checker-c0e7b9c7d3dd295f2d432c096508fcffbcbbc837.tar.bz2 perl_checker-c0e7b9c7d3dd295f2d432c096508fcffbcbbc837.tar.xz perl_checker-c0e7b9c7d3dd295f2d432c096508fcffbcbbc837.zip |
recognize a form of "find { ... } ..."
Diffstat (limited to 'perl_checker.src/parser_helper.ml')
-rw-r--r-- | perl_checker.src/parser_helper.ml | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index d80de58..7c61f1b 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -743,6 +743,13 @@ let cook_call_op op para pos = | Call_op("if infix", [ List [ Call(Deref(I_func, Ident(None, "push", _)), [ Deref(I_array, Ident _) as l; _ ]) ] ; _ ], _) -> let l = string_of_fromparser l in warn_rule [Warn_suggest_functional] (sprintf "use \"push %s, map { ... ? ... : () } ...\" instead of \"foreach (...) { push %s, ... if ... }\"\n or sometimes \"%s = map { ... ? ... : () } ...\"\n or sometimes \"%s = map { if_(..., ...) } ...\"" l l l l) + + | Call_op ("if", [ _; Block [ List [ Call_op("=", [Deref(I_scalar, _) as ret; Deref(I_scalar, Ident(None, "_", _)) ], _) ]; + Semi_colon; + List [ Deref(I_func, Ident(None, "last", _)) ]; + Semi_colon ] ], _) -> + warn_rule [Warn_suggest_functional; Warn_MDK_Common] (sprintf "use \"%s = find { ... } ...\"" (string_of_fromparser ret)) + | List [ Call(Deref(I_func, Ident(None, "push", _)), [ Deref(I_array, Ident _) as l; _ ]) ] -> let l = string_of_fromparser l in warn_rule [Warn_suggest_functional] (sprintf "use \"push %s, map { ... } ...\" instead of \"foreach (...) { push %s, ... }\"\n or sometimes \"%s = map { ... } ...\"" l l l) |