Skip to content

feat(HIS): add COMF his metric - #77

Open
AfonsoSantos96 wants to merge 3 commits into
wip/his-metricsfrom
feat/his_comments
Open

feat(HIS): add COMF his metric#77
AfonsoSantos96 wants to merge 3 commits into
wip/his-metricsfrom
feat/his_comments

Conversation

@AfonsoSantos96

@AfonsoSantos96 AfonsoSantos96 commented Nov 22, 2023

Copy link
Copy Markdown

This PR introduces the feature of checking the comment density within a file.
A file must have a minimum comment density of 0.2.
Two tools are used in this checker. The pmccabe counts the number of statements and the pygount counts the number of comments.
According to the HIS metrics, the comment density is given by the relationship between the number of comments (outside of and within functions) to the number of statements.
So the density is calculated by dividing the total comments (in the file) by the total number of statements (in the file).
As the comments tool also counts the license comments, I have created a variable license_comment_size to remove these comments from the density metric.


Edited by @danielRep :
To test with https://github.com/bao-project/bao-his-tests just run the command make ci METRIC=comf.

Checklist:

  • Tested using the bao-his-tests repo on branch.
  • Compared and validated outputs to ECLAIR his metrics assessment on bao-his-tests repo
  • I have run the CI checkers before submitting the PR to avoid unnecessary runs of the workflow.

Comment thread his_checker.py Outdated
Comment thread his_checker.py Outdated
Comment thread his_checker.py Outdated
Comment thread his_checker.py Outdated
@josecm josecm self-assigned this Feb 16, 2024
@danielRep
danielRep force-pushed the wip/his-metrics branch 5 times, most recently from c1452fe to 4a2edbb Compare February 27, 2024 17:00
@danielRep danielRep changed the title feat(HIS): add file comment density checker feat(HIS): add COMF his metric Feb 29, 2024
@danielRep
danielRep marked this pull request as draft February 29, 2024 13:38
Signed-off-by: Afonso Santos <afomms@gmail.com>
Signed-off-by: Afonso Santos <afomms@gmail.com>
@danielRep
danielRep force-pushed the feat/his_comments branch 2 times, most recently from da904be to 93d77c1 Compare March 6, 2024 17:43
Signed-off-by: Afonso Santos <afomms@gmail.com>
@danielRep
danielRep force-pushed the feat/his_comments branch from 93d77c1 to 6a8f110 Compare March 7, 2024 12:35
@danielRep

Copy link
Copy Markdown
Member

Updated with the modifications introduced in #68 and changed the output format.

@miguelafsilva5 @josecm
Use the testing repo (https://github.com/bao-project/bao-his-tests) has a dummy testbed for each individual metric verified by the HIS checker.
You only need to clone the repo, checkout the ci to this branch, and then make ci METRIC=comf.

@danielRep
danielRep marked this pull request as ready for review March 7, 2024 12:37
@miguelafsilva5

Copy link
Copy Markdown
Member

I don't know if I'm doing anyhing wrong, but this checker seems to be ignoring inline comments. For example:

    int num1 = 3; /* this doesn't count*/
    int num2 = 4; // this doesn't count

@danielRep

danielRep commented Mar 25, 2024

Copy link
Copy Markdown
Member

I don't know if I'm doing anyhing wrong, but this checker seems to be ignoring inline comments. For example:

    int num1 = 3; /* this doesn't count*/
    int num2 = 4; // this doesn't count

That's actually a good point that I didn't take into account. From my analysis, neither pygount, slocount, cloc, tokei, analyzo, or cocnt count inline comments, which is a problem. They consider those lines as a source code line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants