Cha*_*les 21 perl lint static-code-analysis
我正在为Perl寻找一个lint,它可以捕获死代码和其他潜在的问题.有什么建议?
我有
use strict;
use warnings;
Run Code Online (Sandbox Code Playgroud)
已经但我想要更多.
Stu*_*att 20
Perl ::评论家是你的朋友.我使用Test :: Perl :: Critic并将其构建到我的代码的作者测试中
Mic*_*man 11
Perl没有直接相当于lint.其中很大一部分原因是Perl没有提供像C一样多的方法来挂起自己.Perl的"lint"的基本版本是这样的:
perl -Mstrict [-Mdiagnostics] -cw <file>
Run Code Online (Sandbox Code Playgroud)
这会导致perl在打开限制和警告的情况下编译(但不运行)指定的文件.如果您想要更详细的消息,可以使用诊断程序,或者如果简洁的消息足够您可以将其保留.
如果你想要更多的东西尝试使用Perl :: Critic,但要注意这不是真正的lint.lint主要关注错误(例如,会阻止编译,触发运行时错误,不可移植,依赖于未定义的行为等).Perl :: Critic更专注于编码标准的实施.虽然有一些重叠,但它们是完全不同的东西.
使用B::Lint.您可以通过O使用Lint作为参数调用模块在命令行上使用它,例如:
you@there:~/sandbox$ perl -MO=Lint Some.pm
Implicit scalar context for array in logical and (&&) at Some.pm line 121
Implicit scalar context for array in conditional expression at Some.pm line 49
Implicit scalar context for array in logical and (&&) at Some.pm line 132
Some.pm syntax OK
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10179 次 |
| 最近记录: |