#scc #cloc #loc #sloc #month #arguments #tokei

bin+lib cocomo

COCOMO (Constructive Cost Model) CLI utility and library

24 unstable releases (9 breaking)

new 0.10.3 Apr 16, 2025
0.10.2 Feb 21, 2025
0.10.1 Dec 5, 2024
0.10.0 Oct 26, 2024
0.7.1 Jun 24, 2023

#663 in Text processing

Download history 1/week @ 2025-01-07 2/week @ 2025-02-11 125/week @ 2025-02-18 21/week @ 2025-02-25 5/week @ 2025-03-04 5/week @ 2025-03-11 1/week @ 2025-04-08 145/week @ 2025-04-15

146 downloads per month

MIT license

23KB
346 lines

About

CLI and library implementation of COCOMO (Constructive Cost Model) estimates using tokei as a library to calculate total SLOC and scc as reference

See also tokei#359.

Usage

$ cocomo -h
COCOMO (Constructive Cost Model) CLI utility and library

<https://crates.io/crates/cocomo> / <https://github.com/qtfkwk/cocomo>

See also: <https://en.wikipedia.org/wiki/COCOMO>

---

Usage: cocomo [OPTIONS] [PATH]...

Arguments:
  [PATH]...  Files / Directories [default: .]

Options:
      --sloc <N>
          Source lines of code [default: *calculate from Files / Directories
          argument(s)*]
      --average-wage <f64>
          Average Wage [default: 56286.0]
      --inflation-multiplier <f64>
          Inflation multiplier [default: 1.0]
      --inflation-year <usize>
          Inflation year (1995-2024) [default: 1995]
      --overhead <f64>
          Overhead [default: 2.4]
      --eaf <f64>
          Effort Adjustment Factor (EAF); typically 0.9 - 1.4 [default: 1.0]
      --project-type <TYPE>
          Project type (organic: "--custom 2.4,1.05,0.38", embedded: "--custom
          3.6,1.20,0.32", semi-detached: "--custom 3.0,1.12,0.35") [default:
          organic] [possible values: embedded, organic, semi-detached]
      --custom <f64,f64,f64>
          Custom parameters (a, b, c) [default: "2.4,1.05,0.38" ("--project-type
          organic")]
      --development-time <f64>
          Development time (d) [default: 2.5]
      --currency-symbol <STRING>
          Currency symbol [default: $]
  -o, --output-format <FORMAT>
          Output format [default: markdown-table] [possible values:
          markdown-table, sloccount, sloccount-inflation]
  -h, --help
          Print help (see more with '--help')
  -V, --version
          Print version
$ cocomo -V
cocomo 0.10.3

Examples

Use tokei CLI to count lines of code in a given directory

$ tokei ~/github.com/XAMPPRocky/tokei
===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 BASH                    4           48           30           10            8
 JSON                    1         2050         2050            0            0
 Shell                   1           49           38            1           10
 TOML                    3          126          105            5           16
-------------------------------------------------------------------------------
 HTML                    1           12            9            1            2
 |- JavaScript           1           15           11            4            0
 (Total)                             27           20            5            2
-------------------------------------------------------------------------------
 Markdown                5         1720            0         1391          329
 |- BASH                 1            3            3            0            0
 |- JSON                 1           46           46            0            0
 |- Rust                 1            7            4            3            0
 |- Shell                1           16           14            0            2
 (Total)                           1792           67         1394          331
-------------------------------------------------------------------------------
 Rust                   24         4578         3845          140          593
 |- Markdown            14          394            5          335           54
 (Total)                           4972         3850          475          647
===============================================================================
 Total                  39         8583         6077         1548          958
===============================================================================

Use cocomo CLI to calculate COCOMO estimates

$ cocomo ~/github.com/XAMPPRocky/tokei
Description                | Value
---------------------------|---------------------------------
Total Source Lines of Code | 6,077
Estimated Cost to Develop  | $179,686.45
Estimated Schedule Effort  | 7.16 months
Estimated People Required  | 2.23

Add -o sloccount to use the SLOCCount-style output format

$ cocomo ~/github.com/XAMPPRocky/tokei -o sloccount
Total Physical Source Lines of Code (SLOC)                    = 6,077
Development Effort Estimate, Person-Years (Person-Months)     = 1.33 (15.96)
  (Basic COCOMO model, Person-Months = 2.40*(KSLOC**1.05)*1.00)
Schedule Estimate, Years (Months)                             = 0.60 (7.16)
  (Basic COCOMO model, Months = 2.50*(person-months**0.38))
Estimated Average Number of Developers (Effort/Schedule)      = 2.23
Total Estimated Cost to Develop                               = $179,686
  (average salary = $56,286/year, overhead = 2.40)

Pass --sloc N to calculate COCOMO estimates for a given number of lines of code (without counting SLOC in any files or directories)

$ cocomo --sloc 5794
Description                | Value
---------------------------|---------------------------------
Total Source Lines of Code | 5,794
Estimated Cost to Develop  | $170,910.62
Estimated Schedule Effort  | 7.03 months
Estimated People Required  | 2.16

Notes

  1. Prior to version 0.8.0 (2024-08-24), cocomo did not account for inflation, assuming the user could simply modify the default average wage as desired for a given country or other locale and/or time. cocomo now incorporates the USA inflation rates for 1995 (the year that the $56,286 average wage figure comes from) to 2024. The defaults remain the same as before, which means that cocomo gives cost figures in 1995 USD (as it always has, unless its use was customized). Going forward, if you want cocomo to report costs in the current year, please provide it via the --inflation-year option. Note that any given year outside the range above causes cocomo to revert to the inflation multiplier given via the --inflation-multiplier option which is 1.0 by default and effectively represents the year 1995.

Dependencies

~14–27MB
~476K SLoC