Skip to content

feat (HIS): add HIS metrics checker - #68

Open
AfonsoSantos96 wants to merge 6 commits into
mainfrom
wip/his-metrics
Open

feat (HIS): add HIS metrics checker#68
AfonsoSantos96 wants to merge 6 commits into
mainfrom
wip/his-metrics

Conversation

@AfonsoSantos96

@AfonsoSantos96 AfonsoSantos96 commented Oct 23, 2023

Copy link
Copy Markdown

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

josecm commented Oct 26, 2023

Copy link
Copy Markdown
Member

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
Copy Markdown
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

danielRep commented Feb 15, 2024

Copy link
Copy Markdown
Member

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

@danielRep
danielRep marked this pull request as ready for review February 16, 2024 18:29
@danielRep

danielRep commented Feb 16, 2024

Copy link
Copy Markdown
Member

@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>
@danielRep
danielRep force-pushed the wip/his-metrics branch 2 times, most recently from e298879 to 27fec24 Compare February 27, 2024 11:28
@danielRep danielRep mentioned this pull request Feb 27, 2024
3 tasks
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.

3 participants