summaryrefslogtreecommitdiffstats
path: root/perl_checker.src
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-04-28 11:25:26 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-04-28 11:25:26 +0000
commit767f95853462a202be29435b980552f6c6cdc513 (patch)
tree0881d5f67f8ce4fcf2319beabfcf2b1b7bac4dc9 /perl_checker.src
parent64d80e83af61c1d10b7a26d4db08f4f2369f31cc (diff)
downloadperl_checker-767f95853462a202be29435b980552f6c6cdc513.tar
perl_checker-767f95853462a202be29435b980552f6c6cdc513.tar.gz
perl_checker-767f95853462a202be29435b980552f6c6cdc513.tar.bz2
perl_checker-767f95853462a202be29435b980552f6c6cdc513.tar.xz
perl_checker-767f95853462a202be29435b980552f6c6cdc513.zip
- deprecate "open F, ..." prefering "open(my $F, ...)"
- fix an internal_error
Diffstat (limited to 'perl_checker.src')
-rw-r--r--perl_checker.src/parser_helper.ml15
1 files changed, 14 insertions, 1 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index 1e26878..3370d9a 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -86,6 +86,10 @@ let rec un_parenthesize_full = function
| List[e] -> un_parenthesize_full e
| e -> e
+let rec un_parenthesize_full_l = function
+ | [ List l ] -> un_parenthesize_full_l l
+ | l -> l
+
let is_always_true = function
| Num(n, _) -> float_of_string n <> 0.
| Raw_string(s, _) -> s <> ""
@@ -804,6 +808,15 @@ let call_raw force_non_builtin_func (e, para) =
if is_not_a_scalar (List.hd para) then warn_rule "never use \"length @l\", it returns the length of the string int(@l)" ;
None
+ | "open" ->
+ (match para with
+ | [ List(Ident(None, name, _) :: _) ]
+ | Ident(None, name, _) :: _ ->
+ if not (List.member [ "STDIN" ; "STDOUT" ; "STDERR" ]) then
+ warn_rule (sprintf "use a scalar instead of a bareword (eg: occurrences of %s with $%s)" name name)
+ | _ -> ());
+ None
+
| "split" ->
(match para with
| [ List(Call_op("m//", Deref(I_scalar, Ident(None, "_", _)) :: pattern, pos) :: l) ]
@@ -1134,7 +1147,7 @@ let mcontext_check_none msg expr esp =
iter (l_expr, l)
| [], [] -> ()
| _ -> internal_error "mcontext_check_none"
- in iter (l_expr, l)
+ in iter (un_parenthesize_full_l l_expr, l)
| _ -> internal_error "mcontext_check_none")
| _ ->
match expr with