Linux中静态代码分析工具的比较?

时间:2021-04-24 12:51:13

Has anyone done any comparisons on static code analysis tools available to Linux? What are the strengths and weaknesses of the following tools:

有人对Linux可用的静态代码分析工具做过任何比较吗?下列工具的优点和缺点是什么?

  • Lintian,
  • Lintian,
  • Sparse,
  • 稀疏,
  • Splint,
  • 夹板,
  • RATS,
  • 老鼠,
  • Using the -Wall option.
  • 使用- wall选项。

Would you consider that using just one of these tools is adequate?

你认为仅仅使用其中一种工具就足够了吗?

I'm not looking for recommendations (I can find plenty of those) but direct comparisons between available tools.

我不是在寻找推荐(我可以找到很多),而是在可用工具之间进行直接比较。

3 个解决方案

#1


6  

There is of course the wikipedia list. That list is just that, a list, and not a comparison, but one of the links on the page seems to at least partially answer your question and (very briefly) mentions a couple of the programs you listed.

当然还有*的列表。这个列表只是一个列表,而不是一个比较,但是页面上的一个链接似乎至少部分地回答了您的问题,并且(非常简短地)提到了您列出的几个程序。

#2


4  

Using -Wall should be a matter of course for every c developer. Also, additionally using -Wextra could be a good idea.

对于每个c开发人员来说,使用-Wall应该是理所当然的事情。另外,使用-Wextra也是个好主意。

Splint can find other potential weaknesses in your application but in most cases (!) it prints false warnings so you have to really understand what splint means with what warning and most times you have to insert annotations like /out/ or /unused/ in your code so splint doesn't yell on you. With splint, you should filter out warnings which are not important for you, otherwise you spent too much time in analyzing and scrolling through lots of messages.

夹板可以找到其他潜在的弱点在您的应用程序,但在大多数情况下(!)它打印错误警告你有真正理解什么是夹板和警告,大多数时候你必须喜欢/ /或/未使用/插入注释代码中所以夹板不喊你。使用splint,您应该过滤掉对您不重要的警告,否则您将花费大量时间来分析和滚动大量消息。

Note that these tools do only static code checking. You should use valgrind to find runtime memory leaks.

注意,这些工具只执行静态代码检查。您应该使用valgrind查找运行时内存泄漏。

#3


3  

I have used splint a couple of times and found it too verbose: I disabled most of the warnings. I think that this tool may provide interesting results if you correctly annotate your code. Without code annotation, this tool is not very helpful.

我用过几次夹板,发现它太冗长:我禁用了大多数警告。如果您正确地注释了代码,我认为这个工具可以提供有趣的结果。没有代码注释,这个工具不是很有用。

I sometimes use sparse and consider it as a valuable tool. It provides a wrapper around gcc, called "cgcc". As a result, it is simple to run sparse on a program even if it contains many source files (export CC=cgcc and voilà). This program works best if you are analyzing Kernel source code.

我有时使用稀疏,并认为它是一个有价值的工具。它为gcc提供了一个包装,称为“cgcc”。因此,即使程序包含许多源文件(export CC=cgcc和voila),在程序上运行稀疏也是很简单的。如果您正在分析内核源代码,那么这个程序的工作效果最好。

As a sidenote, I also use pmccabe on a regular basis. pmccabe is not a static analyzer: it calculates cyclomatic complexity. It may help you find the most complex functions in your program. Those functions are likely to be error prone and hard to test.

作为旁注,我还经常使用pmccabe。pmccabe不是静态分析器:它计算圈复杂度。它可以帮助您找到程序中最复杂的函数。这些函数很容易出错,也很难测试。

#1


6  

There is of course the wikipedia list. That list is just that, a list, and not a comparison, but one of the links on the page seems to at least partially answer your question and (very briefly) mentions a couple of the programs you listed.

当然还有*的列表。这个列表只是一个列表,而不是一个比较,但是页面上的一个链接似乎至少部分地回答了您的问题,并且(非常简短地)提到了您列出的几个程序。

#2


4  

Using -Wall should be a matter of course for every c developer. Also, additionally using -Wextra could be a good idea.

对于每个c开发人员来说,使用-Wall应该是理所当然的事情。另外,使用-Wextra也是个好主意。

Splint can find other potential weaknesses in your application but in most cases (!) it prints false warnings so you have to really understand what splint means with what warning and most times you have to insert annotations like /out/ or /unused/ in your code so splint doesn't yell on you. With splint, you should filter out warnings which are not important for you, otherwise you spent too much time in analyzing and scrolling through lots of messages.

夹板可以找到其他潜在的弱点在您的应用程序,但在大多数情况下(!)它打印错误警告你有真正理解什么是夹板和警告,大多数时候你必须喜欢/ /或/未使用/插入注释代码中所以夹板不喊你。使用splint,您应该过滤掉对您不重要的警告,否则您将花费大量时间来分析和滚动大量消息。

Note that these tools do only static code checking. You should use valgrind to find runtime memory leaks.

注意,这些工具只执行静态代码检查。您应该使用valgrind查找运行时内存泄漏。

#3


3  

I have used splint a couple of times and found it too verbose: I disabled most of the warnings. I think that this tool may provide interesting results if you correctly annotate your code. Without code annotation, this tool is not very helpful.

我用过几次夹板,发现它太冗长:我禁用了大多数警告。如果您正确地注释了代码,我认为这个工具可以提供有趣的结果。没有代码注释,这个工具不是很有用。

I sometimes use sparse and consider it as a valuable tool. It provides a wrapper around gcc, called "cgcc". As a result, it is simple to run sparse on a program even if it contains many source files (export CC=cgcc and voilà). This program works best if you are analyzing Kernel source code.

我有时使用稀疏,并认为它是一个有价值的工具。它为gcc提供了一个包装,称为“cgcc”。因此,即使程序包含许多源文件(export CC=cgcc和voila),在程序上运行稀疏也是很简单的。如果您正在分析内核源代码,那么这个程序的工作效果最好。

As a sidenote, I also use pmccabe on a regular basis. pmccabe is not a static analyzer: it calculates cyclomatic complexity. It may help you find the most complex functions in your program. Those functions are likely to be error prone and hard to test.

作为旁注,我还经常使用pmccabe。pmccabe不是静态分析器:它计算圈复杂度。它可以帮助您找到程序中最复杂的函数。这些函数很容易出错,也很难测试。