diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-01-16 13:31:19 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-01-16 13:31:19 +0000 |
commit | ce11b3962914f3d82a64738c1a2a14c8c756d3a4 (patch) | |
tree | 9e887ca79f3eb2a5a10caa48f620f451f65610bb /perl_checker.src/parser_helper.ml | |
parent | f42df61f5ac0c22a9283b2cd0feac70a602eac5c (diff) | |
download | perl_checker-ce11b3962914f3d82a64738c1a2a14c8c756d3a4.tar perl_checker-ce11b3962914f3d82a64738c1a2a14c8c756d3a4.tar.gz perl_checker-ce11b3962914f3d82a64738c1a2a14c8c756d3a4.tar.bz2 perl_checker-ce11b3962914f3d82a64738c1a2a14c8c756d3a4.tar.xz perl_checker-ce11b3962914f3d82a64738c1a2a14c8c756d3a4.zip |
- perl_checker:
- check occurences of "$foo ? $foo : $bar"
- disallow "fq::f args" when args is not parenthesized
Diffstat (limited to 'perl_checker.src/parser_helper.ml')
-rw-r--r-- | perl_checker.src/parser_helper.ml | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index d04e79f..e1633fb 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -265,6 +265,15 @@ let check_parenthesized_first_argexpr word ((_, e), (_, (start, _)) as ex) = if word = "time" then die_rule "please use time() instead of time"; sp_p(ex) +let check_parenthesized_first_argexpr_with_Ident ident ((_, e), _ as ex) = + (match ident with + | Ident(Some _, _, _) -> + (match e with + | [e] when is_parenthesized e -> () + | _ -> warn_rule "use parentheses around argument (otherwise it might cause syntax errors if the package is \"require\"d and not \"use\"d") + | _ -> ()); + check_parenthesized_first_argexpr (string_of_Ident ident) ex + let check_hash_subscript ((_, e), (_, pos)) = let can_be_raw_string = function | "" | "x" | "y" -> false (* special case for {'y'} otherwise the emacs mode goes wild, special case for {'x'} to have the same as {'y'} (since they usually go together) *) @@ -308,6 +317,7 @@ let check_ternary_paras(cond, a, b) = in if dont_need_short_circuit a || is_same_fromparser cond a then check_ternary_para b; if dont_need_short_circuit b || is_same_fromparser cond b then check_ternary_para a; + if is_same_fromparser cond a && dont_need_short_circuit b then warn_rule "you can replace \"$foo ? $foo : $bar\" with \"$foo || $bar\""; [ cond; a; b ] let check_unneeded_var_dollar_ ((_, e), (_, pos)) = |