SLOCCOUNT(1)

πŸ“¦
version 2.26 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ SLOCCOUNT πŸ’– (that's the sloccount command from the SLOCCount package, bestie)

okay so first things first, the manual name is SLOCCOUNT(1) β€” that's the page you're reading, and the whole vibe is "count your code, queen." Let's go. 🫢


🌸 NAME 🌸

sloccount β€” count source lines of code (SLOC). that's it, that's the job. πŸ’…


✨ SYNOPSIS ✨

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

like, that's a LOT of flags, but don't panic, we're gonna walk through every single one. πŸ¦‹


πŸŽ€ DESCRIPTION πŸŽ€

so sloccount counts the physical source lines of code (SLOC) chilling inside the descendants of whatever set of directories you hand it. it's giving detective energy: it automatically figures out which files are even source code files, and it automatically sniffs out which computer language each file is written in. by default it summarizes the SLOC results and throws in a bunch of estimates (effort! cost to develop! etc.), but you can control all that output with the options. iconic. πŸ‘‘

if you give sloccount a list of two or more directories, the counts get broken up according to that list. but there's one important limitation, and no, you cannot skip this part: the basenames of the directories you pass as parameters have to be different, because those names are literally what's used to group the summary information. so like, you can NOT run sloccount /usr/src/hello /usr/local/src/hello β€” that's a no from the tool. 🚫 this limitation only applies to the parameters of sloccount itself β€” subdirectories descended from the top directories are allowed to have the same basename, so breathe.

if you give sloccount only a single directory, it tries to automatically find a reasonable breakdown for reporting purposes (so it'll produce a useful report, because it wants you to thrive). in that case:

  • if the directory has at least two subdirectories, then those subdirectories get 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 get assigned to the directory top_dir so you can tell them apart from the other contents.
  • finally, if there's a subdirectory named src, then that subdirectory gets broken down again, with all the further subdirectories prefixed with src_. so if directory X has a subdirectory src, which contains subdirectory modules, sloccount will report a separate count for src_modules. the way that naming scheme just WORKS. πŸ”₯

sloccount normally considers all descendants of these directories, though unless you tell it 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. capitalization matters, iykyk. πŸ™ˆ

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. main character energy: you're in charge of the numbers. πŸ’œ


πŸ’– OPTIONS πŸ’–

  • --version β€” report the version number of SLOCCount and immediately exit. this option can't be usefully combined with any other option, so don't try to make it do double duty. 😭
  • --cached β€” do not recalculate; instead, use cached results from a previous execution. without the --cached or --append option, sloccount automatically removes the data directory and recreates it. so like, it's got memory. 🧠
  • --append β€” do not remove previous calculations from the data directory; instead, add the analysis to the current contents of the data directory. hoarding behavior, but make it analytics. πŸ“
  • --datadir directory β€” store or use cached data in the given data directory; default value is ~/.slocdata. ✨
  • --follow β€” follow symbolic links. πŸ¦‹
  • --duplicates β€” count all duplicates. normally, if files have equal content (as determined using MD5 hash values), only one is counted. πŸ”
  • --crossdups β€” count duplicates if they occur in different portions of the breakdown. thus, if the top directory contains many different projects, and you want the duplicates in different projects to count in each project, choose this option. 🌈
  • --autogen β€” count source code files that appear to be automatically generated. normally these are excluded. (yes, the robots' code counts too, if you insist.) πŸ€–
  • --multiproject β€” the different directories represent different projects; otherwise, it's assumed that all of the source code belongs to a single project. this doesn't change the total number of files or SLOC values, but it does affect the effort and schedule estimates. given this option, effort is computed separately for each project (and then summed), and the schedule is the estimated schedule of the largest project. πŸ’…
  • --filecount β€” display counts of files instead of SLOC. πŸ”’
  • --wide β€” display in the "wide" (tab-separated) format. great for when you're piping stuff around. 🌊
  • --details β€” display details, that is, results for every source code file. no summaries, we want the receipts. 🧾
  • --effort F E β€” change the factor and exponent for the effort model. effort (in person-months) is computed as F*(SLOC/1000)^E. math girlies rise. πŸ“
  • --schedule F E β€” change the factor and exponent for the schedule model. schedule (in months) is computed as F*(effort)^E. ⏳
  • --personcost cost β€” change the average annual salary to cost. πŸ’Έ
  • --overhead overhead β€” change the overhead value to overhead. estimated cost is computed as effort * personcost * overhead. πŸ’°
  • --addlang language β€” add a language not considered by default to be a "language" to be reported. currently the only legal values for language are makefile, sql, and html. these files are not normally included in the SLOC counts, although their SLOCs are internally calculated and they are shown in the file counts. if you want to include more than one such language, do it by passing --addlang more than once, e.g., --addlang makefile --addlang sql. πŸŽ€
  • --addlangall β€” add all languages not normally included in final reports. ✨

🫢 NOTES 🫢

as with many other programs using Unix-like options, directories whose names begin with a dash (-) can be misinterpreted as options. so if the directories you want analyzed might begin with a dash, use the double-dash (--) to indicate the end of the option list before listing the directories. classic Unix moment, honestly. 😭


πŸ’€ BUGS πŸ’€

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. so like, spooky but rare. πŸ™ˆ

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). manifesting this for a future release. ✨


πŸ”₯ SEE ALSO πŸ”₯

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. πŸ“š


πŸ‘‘ AUTHOR πŸ‘‘

David A. Wheeler (dwheeler@dwheeler.com). king behavior. πŸ’œ


and that's the whole page bestie β€” this one's from SLOCCount, dated 31 July 2004, and it's the SLOCCOUNT(1) manual page. go count some lines, you absolute legend. πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from