分析并生成代码统计信息

发布于 2024-08-08 12:18:35 字数 163 浏览 2 评论 0原文

我想知道是否有人有任何想法或程序来生成源代码的一般统计信息。

我突然想知道我的项目代码中有多少函数被调用一次或很少次,或者任何类只实例化一次。

我确信还有很多其他有趣的事情有待发现。

我可以使用 grep magic 做类似上面的事情,但是有人遇到过工具或技巧吗?

I was wondering if anyone had any ideas or procedures for generating general statistics on your source code.

Off the top of my head I would love to know how many functions in my project's code are called once or very few times or any classes that are only instantiated once.

I'm sure there is a ton of other interesting things to be found out.

I could do something like the above using grep magic but has anyone come across tools or tips?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

思念满溢 2024-08-15 12:18:35

Coverity 是我首先想到的。它目前提供(在其产品之一上)

  • 软件 DNA Map™ 分析系统:生成整个构建系统的全面表示,包括对每行代码进行语义上正确的解析。
  • 缺陷管理器:直观的界面可以轻松建立缺陷的所有权并通过反映您现有开发流程的定制工作流程解决它们。
  • 本地分析:允许在开发人员桌面上本地分析代码,以在与其他开发人员共享之前确保质量。
  • 布尔可满足性:将代码转换为基于布尔值的问题,然后应用 SAT 求解器来实现最准确的缺陷检测和最低的误报率。 Only Prevent 提供了这种专有方法的更高精确度。
  • 竞争条件检查器:具有业界第一的竞争条件检查器,专为当今复杂的多线程应用程序而构建。
  • 路径模拟:模拟 100% 的所有值和数据路径,从而能够检测到最关键的缺陷。
  • 统计与统计过程间分析:通过根据先前观察到的行为推断正确的行为并执行类似于执行 Bin 的整个程序分析,确保对整个构建系统进行全面分析。
  • 错误路径修剪:有效消除误报,使预防的平均 FP 率约为 15%,一些用户报告 FP 率低至 5%。
  • 增量分析:整体或增量分析源代码,使您可以通过仅检查受更改影响的组件来节省时间。
  • 报告:通过可定制的报告衡量一段时间内的软件质量趋势,以便您可以显示按检查器、分类、组件和其他缺陷信息分组的缺陷。

Coverity is the first thing coming to mind. It currently offers (on one of their products)

  • Software DNA Map™ analysis system: Generates a comprehensive representation of the entire build system including a semantically correct parsing of every line of code.
  • Defect Manager: Intuitive interface makes it easy to establish ownership of defects and resolve them via a customized workflow that mirrors your existing development process.
  • Local Analysis: Enables code to be analyzed locally on developers’ desktops to ensure quality before sharing with other developers.
  • Boolean Satisfiability: Translates the code into questions based on Boolean values, then applies SAT solvers for the most accurate defect detection and the lowest false positive rate available. Only Prevent offers the added precision of this proprietary method.
  • Race Conditions Checker: Features an industry-first race conditions checker built specifically for today’s complex multi-threaded applications.
  • Path Simulation: Simulates 100% of all values and data paths, enabling detection of the most critical defects.
  • Statistical & Interprocedural Analysis: Ensures a comprehensive analysis of your entire build system by inferring correct behavior based on previously observed behavior and performing whole-program analysis similar to the executing Bin.
  • False Path Pruning: Efficiently removes false positives to give Prevent an average FP rate of about 15%, with some users reporting FP rates of as low as 5%.
  • Incremental Analysis: Analyzes source code wholly or incrementally, allowing you to save time by checking only those components that are affected by a change.
  • Reporting: Measures software quality trends over time via customizable reporting so you can show defects grouped by checker, classification, component, and other defect information.
总以为 2024-08-15 12:18:35

有很多工具可以做到这一点。但据我所知,它们都不是独立于语言的(这基本上是不可能的,例如某些语言甚至可能没有函数)。

通常,您会在“代码覆盖工具”或“分析器”类别下找到这些工具。

对于.Net,您可以使用Visual Studio 或Clrprofiler。

There are lots of tools that do this. But afaik none of them are language independent (which in turn would be mostly impossible e.g. some languages might not even have functions).

Generally you will find those tools under the categories of "code coverage tools" or "profilers".

For .Net you can use Visual Studio or Clrprofiler.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文