Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(HIS): add COMF his metric #77

Open
wants to merge 3 commits into
base: wip/his-metrics
Choose a base branch
from

Conversation

AfonsoSantos96
Copy link
Member

@AfonsoSantos96 AfonsoSantos96 commented Nov 22, 2023

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.

his_checker.py Outdated Show resolved Hide resolved
his_checker.py Outdated Show resolved Hide resolved
his_checker.py Outdated Show resolved Hide resolved
his_checker.py Outdated Show resolved Hide resolved
@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
Copy link
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
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
Copy link
Member

danielRep commented Mar 25, 2024

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.

None yet

4 participants