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

Problem with the message returned when type coverage tests fail #29

Closed
carlos-granados opened this issue Mar 15, 2024 · 6 comments · Fixed by #31
Closed

Problem with the message returned when type coverage tests fail #29

carlos-granados opened this issue Mar 15, 2024 · 6 comments · Fixed by #31

Comments

@carlos-granados
Copy link
Contributor

I have a project which I was testing using this library. For return types, if I set the return type coverage level to 66 I get this message:

Out of 9930 possible return types, only 6551 - 66.0 % actually have it. Add more return types to get over 66

The problem here is that the message seems to imply that my actual coverage is 66.0% but it is actually 6551/9930 = 65.97%. If we are rounding we should round down so that we show a value that, if the user sets in the config, the tests will pass. Otherwise the message just looks weird and leaves you wondering what you did wrong.

Another problem is that if I use the new possibility to use floats and I set the value, for example, to 66.1 I get the same message. The "Add more return types to get over" part should use the float value, not the rounded value

@TomasVotruba
Copy link
Owner

Thanks 👍

Just a rough fix - could you verify it helps you use case?
#30

@carlos-granados
Copy link
Contributor Author

This does not work OK, I commented on the PR.

Also this only fixes the first problem I reported. There is still the second problem

@carlos-granados
Copy link
Contributor Author

This second problem can be solved by changing

    public const ERROR_MESSAGE = 'Out of %d possible return types, only %d - %.1f %% actually have it. Add more return types to get over %d %%';

to

    public const ERROR_MESSAGE = 'Out of %d possible return types, only %d - %.1f %% actually have it. Add more return types to get over %s %%';

This will print the limit as you have configured it

@TomasVotruba
Copy link
Owner

Thanks 👍 Could you send PR for it?

carlos-granados added a commit to carlos-granados/type-coverage that referenced this issue Mar 15, 2024
@carlos-granados
Copy link
Contributor Author

Done #31

@TomasVotruba
Copy link
Owner

Thanks 👍

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 a pull request may close this issue.

2 participants