LLNL / scraper

Python library for getting metadata from source code hosting tools
MIT License
49 stars 23 forks source link

Calculate person-months of effort in the package #62

Closed mcdonnnj closed 2 years ago

mcdonnnj commented 2 years ago

This pull request changes the calculation of person-months from relying on the tool located at http://softwarecost.org/tools/COCOMO/ to calculating it within the package using the same settings. The labor hours calculation is rounded to the tenths to be consistent with the output of the previous method.

If there is an issue with connecting to the above tool it will cause an unrecoverable failure when using this tool from the CLI. This is especially painful if working over a large number of projects. Since this is a relatively straightforward calculation I thought it prudent to just implement calculating person-months in the package to remove the need to query the tool entirely.

Note: There is a difference in the calculated labor hours value because the above tool rounds the person-months output to the tenths while we have the raw value when calculating it locally. PHP (what the tool appears to be written in) has a default of PHP_ROUND_HALF_UP in the round() function which has the following description:

Rounds num away from zero when it is half way there, making 1.5 into 2 and -1.5 into -2.

Using the CLOC of this branch:

$ cloc --json . | jq '.SUM.code'
3152

Old implementation:

>>> compute_labor_hours(3152)
1580.8

Person-months: 10.4

New implementation:

>>> compute_labor_hours(3152)
1579.4

Person-months: 10.390646842135041

IanLee1521 commented 2 years ago

This is awesome, thank you @mcdonnnj !

mcdonnnj commented 2 years ago

@IanLee1521 Fixed that oversight on my part that caused tests to fail. Everything should pass now.