From e48b0376e4f1e2a423fc847a07c80eb6d4a86c66 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 13 Oct 2004 08:47:26 +0000 Subject: $#x == -1 is better written @x == 0 --- perl_checker.src/parser_helper.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'perl_checker.src/parser_helper.ml') diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index 39a4590..306fc3f 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -702,8 +702,11 @@ let cook_call_op op para pos = | "||=", e :: _ | "&&=", e :: _ -> if is_not_a_scalar e then warn_rule (sprintf "\"%s\" is only useful with a scalar" op) - | "==", [Call_op("last_array_index", _, _); Num("0", _)] -> - warn_rule "$#x == 0 is better written @x == 1" + | "==", [Call_op("last_array_index", _, _); Num(n, _)] -> + warn_rule (sprintf "$#x == %s is better written @x == %d" n (1 + int_of_string n)) + | "==", [Call_op("last_array_index", _, _); Call_op("- unary", [Num (n, _)], _)] -> + warn_rule (sprintf "$#x == -%s is better written @x == %d" n (1 - int_of_string n)) + | "||", e :: _ when is_always_true e -> warn_rule " || ... is the same as " | "&&", e :: _ when is_always_false e -> warn_rule " && ... is the same as " -- cgit v1.2.1