SLOCCOUNT(1) | SLOCCount | SLOCCOUNT(1) |
sloccount - count source lines of code (SLOC)
sloccount [--version] [--cached] [--append] [ --datadir directory ] [--follow] [--duplicates] [--crossdups] [--autogen] [--multiproject] [--filecount] [--wide] [--details] [ --effort F E ] [ --schedule F E ] [ --personcost cost ] [ --overhead overhead ] [ --addlang language ] [ --addlangall ] [--] directories
sloccount counts the physical source lines of code (SLOC) contained in descendants of the specified set of directories. It automatically determines which files are source code files, and it automatically determines the computer language used in each file. By default it summarizes the SLOC results and presents various estimates (such as effort and cost to develop), but its output can be controlled by various options.
If you give sloccount a list of two or more directories, the counts will be broken up according to that list. There is one important limitation: the basenames of the directories given as parameters must be different, because those names are used to group summary information. Thus, you can't run "sloccount /usr/src/hello /usr/local/src/hello". This limitation only applies to parameters of sloccount - subdirectories descended from the top directories can have the same basename.
If you give sloccount only a single directory, sloccount tries to automatically find a reasonable breakdown for purposes of reporting (so it'll produce a useful report). In this case, if the directory has at least two subdirectories, then those subdirectories will be used as the breakdown. If the single directory contains files as well as directories (or if you give sloccount some files as parameters), those files will be assigned to the directory "top_dir" so you can tell them apart from other contents. Finally, if there's a subdirectory named "src", then that subdirectory is again broken down, with all the further subdirectories prefixed with "src_". Thus, if directory "X" has a subdirectory "src", which contains subdirectory "modules", sloccount will report a separate count for "src_modules".
sloccount normally considers all descendants of these directories, though unless told otherwise it ignores symbolic links.
sloccount is the usual front-end of the package of tools named "SLOCCount". Note that the name of the entire package has capital letters, while the name of this front-end program does not.
sloccount will normally report estimates of schedule time, effort, and cost, and for single projects it also estimates the average number of active developers. These are merely estimates, not etched in stone; you can modify the parameters used to improve the estimates.
As with many other programs using Unix-like options, directories whose names begin with a dash (``-'') can be misinterpreted as options. If the directories to be analyzed might begin with a dash, use the double-dash (``- -'') to indicate the end of the option list before listing the directories.
Filenames with embedded newlines (in the directories or their descendants) won't be handled correctly; they will be interpreted as separate filenames where the newlines are inserted. An attacker could prevent sloccount from working by creating filenames of the form /normal/directory ... NEWLINE/dev/zero. Such filenames are exceedingly rare in source code because they're a pain to work with using other tools, too. Future versions of sloccount may internally use NUL-separated filenames (like GNU find's -print0 command) to fix this.
There are many more languages not yet handled by SLOCCount.
SLOCCount only reports physical source lines of code. It would be very useful if it could also report logical lines of code, and perhaps other common metrics such as McCabe's complexity measures and complexity density (complexity/SLOC for each function or procedure).
See the SLOCCount website at http://www.dwheeler.com/sloccount. Note that more detailed documentation is available both on the website and with the SLOCCount package.
David A. Wheeler (dwheeler@dwheeler.com).
31 July 2004 | SLOCCount |