What tools do you use for static code analysis? [c

2020-05-11 10:37发布

This question on Cyclomatic Complexity made me think more about static code analysis. Analyzing code complexity and consistency is occasionally useful, and I'd like to start doing it more. What tools do you recommend (per language) for such analysis? Wikipedia has a large list of tools, but which ones have people tried before?

Edit: As David points out, this is not a completely unasked question when it comes to C/UNIX based tools.

14条回答
贼婆χ
2楼-- · 2020-05-11 10:56

For .Net we use NDepend. It is a great tool and can be integrated to the build (we use CCNet).

http://www.ndepend.com/

HTH.

查看更多
Rolldiameter
3楼-- · 2020-05-11 10:57

I've used quite a few open-source and commercial static analysis tools across many languages and I find that the overall discussion fits under the umbrella of a concept known as technical debt (which this article goes into detail about).

However for a quick answer, here are my favorites per language:

查看更多
迷人小祖宗
4楼-- · 2020-05-11 11:00

Checkstyle, Findbugs, and PMD all work pretty well in Java. I'm currently pretty happy with PMD running in NetBeans. It has a fairly simple GUI for managing what rules you want to run. It's also very easy to run the checker on one file, an entire package, or an entire project.

查看更多
小情绪 Triste *
5楼-- · 2020-05-11 11:00

My admins are really cheap, so can I only use really cheap tools:

1) CCCC (C / C++ Code Counter): Various results related to number of lines (vs. lines of comments, cyclomatic complexity, Information flow, ...) 2) Semian: Fastest code duplication finder I ever tried. 3) LOC Metrix: Not very usefull but can help to make a point.

查看更多
我命由我不由天
6楼-- · 2020-05-11 11:01

Obviously, the answer depends on the programming languages. UNO is good for C programs.

@Thomas Owens: I think you meant Splint.

查看更多
劫难
7楼-- · 2020-05-11 11:01

We use Coverity Prevent at Palm for C and C++ code analysis, and it's done a great job of uncovering some hidden bugs in our code. It also finds a lot of not likely to be hit problems, but it's easy to mark those as "will not fix" or "not a problem" in the code database that the tool generates. It is expensive, but the company occasionally does runs on open source projects and provides reports to the maintainers. They have a whitepaper about our use of the product on their site if you want to read more about our experience.

查看更多
登录 后发表回答