boyter / scc

Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go
MIT License
6.28k stars 250 forks source link

Feature Request - Include COCOMO in sql, sql-insert output #381

Closed adam-moss closed 2 months ago

adam-moss commented 1 year ago

Hi,

I've been using this tool for a while, and finally ran it across the org's entire codebase.

One thing I've noticed is the COCOMO calculation isn't included in the sql or sql-insert output format.

Would it be possible for this to be added?

Unfortunately my go knowledge is almost nil so otherwise I'd look to contribute it myself.

Thanks!

boyter commented 1 year ago

So it's not that complex to add yourself if you need but sure I don't see why not. By add it yourself I mean inside the CSV output itself, or calculate in SQL. But adding it seems fine.

therohitdas commented 6 months ago

Hi, @boyter, Can we have COCOMO calculations in other file types too? For example JSON and HTML?

boyter commented 6 months ago

Yep shouldn't be a huge issue.

boyter commented 2 months ago

OK... so adding to the JSON will break backwards compatibility... I should have wrapped the output. I think the best option might be to add json2 as another output format, which will work better and deal with this.

boyter commented 2 months ago

COCOMO calculation now on HTML in c8b4c8b65dc2f5875742db6eda0531d2d12b371f and will make it into the next release. Still working on the JSON one, but there will be a new option JSON2 which will cater for this case.

boyter commented 2 months ago

COCOMO now in the SQL as well.

$ sqlite3 code.db
SQLite version 3.43.2 2023-10-10 13:08:14
Enter ".help" for usage hints.
sqlite> .tables
metadata  t       
sqlite> select * from metadata;
2024-05-02 14:52:05|./processor|0.013|191388.454422|7.337397|2.317339
sqlite> 

It has been added on the metadata table so you can get the value for each run if required.

boyter commented 2 months ago
$ scc -f json2 ./processor | jq
{
  "languageSummary": [
    {
      "Name": "Go",
      "Bytes": 372325,
      "CodeBytes": 0,
      "Lines": 8233,
      "Code": 6482,
      "Comment": 415,
      "Blank": 1336,
      "Complexity": 1412,
      "Count": 23,
      "WeightedComplexity": 0,
      "Files": []
    }
  ],
  "estimatedCost": 192260.38345980726,
  "estimatedScheduleMonths": 7.350081964914843,
  "estimatedPeople": 2.3238791399621794
}

Now in JSON with the new json2 format in 32db2f5cae9eaab5583b013b9e0697a477c453e9 which will make it into the next release.