Skip to content

radon hal yields Halstead complexity measures of zero for complex files #266

Description

@fmv1992

Are these metrics expected for these cases?

f1.py:
    h1: 0
    h2: 0
    N1: 0
    N2: 0
    vocabulary: 0
    length: 0
    calculated_length: 0
    volume: 0
    difficulty: 0
    effort: 0
    time: 0.0
    bugs: 0.0
f2.py:
    h1: 1
    h2: 2
    N1: 1
    N2: 2
    vocabulary: 3
    length: 3
    calculated_length: 2.0
    volume: 4.754887502163469
    difficulty: 0.5
    effort: 2.3774437510817346
    time: 0.1320802083934297
    bugs: 0.0015849625007211565
f3.py:
    h1: 2
    h2: 4
    N1: 2
    N2: 4
    vocabulary: 6
    length: 6
    calculated_length: 10.0
    volume: 15.509775004326936
    difficulty: 1.0
    effort: 15.509775004326936
    time: 0.861654166907052
    bugs: 0.005169925001442312

Cases:

./f1.py
-------------------------------------------------------------------------------
class A:
    a = 1
    b = 2
-------------------------------------------------------------------------------
./f2.py
-------------------------------------------------------------------------------
class A:
    a = 1
    b = 2


def main():
    pass


if __name__ == "__main__":
    main()
-------------------------------------------------------------------------------
./f3.py
-------------------------------------------------------------------------------
class A:
    a = 1
    b = 2

    def add(self):
        return self.a + self.b


def main():
    pass


if __name__ == "__main__":
    main()

I guess I don't understand why I'm getting zeros there. An actual pretty complex code that I checked yielded hal metrics with values as 0 and that was surprising to me.

I understand that the code that gets 0 actually does not run anything, but still, it's surprising to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions