Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which tool can show the maximum statements of Method or function in C++? [closed]

Tags:

c++

metrics

our project is really big. the source codes size is about 620KLOC in one module. So I want to check which function is the biggest in a directory/module? Is there any tool can support it?

SourceMonitor only has "Average Statements per Method", not maximum statements per method. CCCC doesn't support it either.

example. This function length is 1.

unsigned short get()
{
    return 1;
}

Thanks.

like image 998
liuzw Avatar asked Oct 22 '22 15:10

liuzw


1 Answers

The easiest thing I can think of is scripting your way through it.

  • Use e.g ctags to get a list of functions in the file
  • Use perl/python/awk/grep to split your source file into separate files, one file per function
  • Simply count the lines of each file, take the maximum length. If you need more details, feed each file into a loc-counter e.g. sloccount to
    get more refined information. Use grep again to get the output you are interested in

Another tool that might be of help:

Lazy C++: Is is a code generator that splits files that are very similar to c++ into header and source. If you write you transform your code into a lzz file the generated code includes line counter tags per function. The differences in those numbers would show you how big your functions are

like image 92
Martin Avatar answered Oct 31 '22 11:10

Martin