Skip to content

(Bug) Halstead Metrics and Ops Output are inconsistent to each other #1183

@MercurCodes

Description

@MercurCodes

I'm currently using the CLI variant to analyze C and Rust code. However, I spotted, that n1 in the Halstead metrics is not corresponding to the operations list generated by the --ops output.
To my understanding the length of the list of operators should correspond with the n1 value in Halstead. This is however using this tool not always the case; neither in a function space nor on the module level.
In our current setup, we actually have on a global space a difference by 4 operators and for multiple functions a difference of 1.

Furthermore, I spotted, that in the list of operators, if one calculates the union of all sets of all operators of all function - spaces, it misses some in the module space. (In my case the 'uint8_t' was used in a function, but is missing from the module space in case of my C analysis. Comparing it to the Rust Version, u8 is present on the module space and on the function space; However, in Rust 'else' is missing from the operator list in the module space, but is present in the function space; Comparing this to the C analysis, 'else' is present there in the module space and in the function space)

Since this bug in my opinion effects the Halstead metrics fundamentally, I wanted to check with you if this bug is known and if there is a fix available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions