tags:

views:

61

answers:

3

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?

A: 

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.
Vinko Vrsalovic
A: 

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.

Foxfire
+2  A: 

Near-duplicate with:

  1. Calculate code Metrics
  2. Code Metrics
...and probably several more, but you get the idea.

Jerry Coffin
Ahhhh metrics was the term I was missing!
Shane