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

list-metrics outputs metrics in unpredictable order #179

Closed
devdanzin opened this issue Jul 4, 2023 · 1 comment
Closed

list-metrics outputs metrics in unpredictable order #179

devdanzin opened this issue Jul 4, 2023 · 1 comment

Comments

@devdanzin
Copy link
Collaborator

The command list-metrics outputs metrics in unpredictable order, which might be confusing for users that expect it to be stable. (e.g. missing some info when skimming the output).

My actual issue was that I'm using ALL_OPERATORS to build an index of HTML reports, and there too the ordering is inconsistent. It seems it comes from using a set to build this dictionary:

"""Dictionary of all operators"""
ALL_OPERATORS = {
    operator.name: operator
    for operator in {
        OPERATOR_CYCLOMATIC,
        OPERATOR_MAINTAINABILITY,
        OPERATOR_RAW,
        OPERATOR_HALSTEAD,
    }
}

This seems to be the root cause of #126. So I'd like to request the feature of stable ordering, likely by changing the set literal to a tuple literal.

I've solved my issue by sorting ALL_OPERATORS.items(), then saw that it also affects list-metrics.

I can submit a PR if it's considered a desirable change.

@tonybaloney
Copy link
Owner

Hm, yes I never considered the set literal would yield different orders.

Please submit a PR and swap that set literal with a tuple literal

devdanzin pushed a commit to devdanzin/wily that referenced this issue Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants