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 HIS metrics checker #68

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

AfonsoSantos96
Copy link
Member

@AfonsoSantos96 AfonsoSantos96 commented Oct 23, 2023

HIS Checker

This PR introduces a new feature on the ci, the HIS metrics checker.
The following table lists the HIS metrics to be implemented, indicating the threshold for each metric (in the Description column).
The PR column contains the link to the PR where the metric check was implemented.


Edited by @danielRep

Metric Description PR Tool Done Ref. by Daniel
CALLING Number of callers (<5) [ ] [ ]
CALLS Number of called functions (<7) #59 cflow [ ] [x]
COMF Ratio of comments to statements (>=0.2) #77 pygount/pmccabe [ ] [x]
v_G Cyclomatic Complexity (<=10) #53 pmccabe [ ] [x]
GOTO Number of Goto (=0) #76 qmcalc [ ] [x]
LEVEL Number of nested conditions (<=4) [ ] [ ]
PARAM Number of function parameters (<=5) #72 cflow [ ] [x]
PATH Number of Paths (<80) [ ] [ ]
AP_CG_CYCLE Recursive Functions (=0) #67 cflow [ ] [ ]
RETURN Number of returns in function (<=1) [ ] [ ]
STMT Number of statements in function (<=50) #74 pmccabe [ ] [x]
VOCF Vocabulary of function (<=4) [ ] [ ]

The MISRA-related metrics are addressed by the misra check (and not this checker):
NOMV: Violations of the HIS subset of MISRA C rules
NOMVP: Violations of the HIS subset of MISRA C rules by rule

The following metrics are currently not addressed since they are related to project evolution and cannot be evaluated in a single commit/snapshot:
SCHG: Number of statements changed in project
SDEL: Number of statements deleted in project
SI: Stability index of project
SNEW: Number of statements added in project

This PR will be used to discuss the overall implementation of the HIS checker and not technical code corrections of each metric (that should be done on the metric PR).

TODO

  • Add tests.

@josecm josecm self-assigned this Oct 26, 2023
@josecm
Copy link
Member

josecm commented Oct 26, 2023

I think an useful information in that table would be if the metric can be computed for each file or has to take the whole project into account.

@AfonsoSantos96
Copy link
Member Author

I think an useful information in that table would be if the metric can be computed for each file or has to take the whole project into account.

That's a good idea! We could add a column that states the granularity of each metric.
I think we could follow this from QA: https://www.qa-systems.com/tools/qa-misra/metrics-and-visualisations/

@danielRep
Copy link
Member

danielRep commented Feb 15, 2024

Additional information regarding the HIS metrics as defined by the consortium (v1.3.1 - last open specification version).
HIS Source Code Metrics.pdf

@danielRep
Copy link
Member

danielRep commented Feb 16, 2024

@josecm @miguelafsilva5 Changed the base script for the HIS metrics to give more flexibility to the script:

  • -f, --files option expects a list of files to be processed (e.g., -f /path/to/src1.c /path/to/hdr1.c)
  • --{metric} options can be used to redefine a default value of the threshold for a specific metric (e.g., --level 200)
  • -e, --exclude can be used to exclude a specific metric from the processing (e.g., -e level)

To try this locally use as e.g.: ./his_checker.py -f src/params/params.c --level 200 -e stmt.

Signed-off-by: Afonso Santos <afomms@gmail.com>
Signed-off-by: Afonso Santos <afomms@gmail.com>
Signed-off-by: Afonso Santos <afomms@gmail.com>
Signed-off-by: Afonso Santos <afomms@gmail.com>
Signed-off-by: Afonso Santos <afomms@gmail.com>
Signed-off-by: Daniel Oliveira <drawnpoetry@gmail.com>
@danielRep danielRep mentioned this pull request Feb 27, 2024
4 tasks
@danielRep danielRep changed the title feat (HIS): HIS metrics checker feat (HIS): add HIS metrics checker Feb 29, 2024
@josecm josecm force-pushed the main branch 2 times, most recently from eede022 to f0fba61 Compare July 16, 2024 10:44
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

3 participants