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

0.8.0-Beta DSL confusion between minBound and minValue. #572

Closed
mgroth0 opened this issue Mar 21, 2024 · 3 comments · Fixed by #578
Closed

0.8.0-Beta DSL confusion between minBound and minValue. #572

mgroth0 opened this issue Mar 21, 2024 · 3 comments · Fixed by #578
Assignees
Labels
Bug Bug issue type S: untriaged Status: issue reported but unprocessed

Comments

@mgroth0
Copy link

mgroth0 commented Mar 21, 2024

I have spent a long time being very confused, stepping through debuggers, and creating a reproducer only to find out that I was using the DSL incorrectly. I think it is a design issue, as it is too easy for users to get mixed up.

I was doing this:

kover {
    reports {
        verify {
            rule {
                bound {
                    coverageUnits.set(CoverageUnit.BRANCH)
                    minBound(75)
                }
            }
        }
    }
}

And my output kept looking like this:

Rule violated: lines covered percentage is 12.500000, but expected minimum is 75

I was very confused why it kept using lines instead of branches. Finally, I discovered I needed to do this:

kover {
    reports {
        verify {
            rule {
                bound {
                    coverageUnits.set(CoverageUnit.BRANCH)
                    minValue = 75 // <-- Change here
                }
            }
        }
    }
}

And now it works:

Rule violated: branches covered percentage is 0.000000, but expected minimum is 75

I think that the correct solution here is to use the @DslMarker annotation on all DSL objects. I mean, create an annotation called KoverDsl, annotate that annotation with @DslMarker, and put KoverDsl on all kover dsl interfaces.

@mgroth0 mgroth0 added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Mar 21, 2024
@shanshin
Copy link
Collaborator

shanshin commented Mar 21, 2024

Hi,
yes, in fact, it was worth adding an @DslMarker annotation a long time ago.

But could you clarify, having encountered the problem, have you looked at the documentation for the bound function?
It may also be worth improving the documentation for it somehow.

@mgroth0
Copy link
Author

mgroth0 commented Mar 21, 2024

I did not look at the documentation, no. I was creating a new reproducer project and was already familiar with the kover API so I was going off memory. However, my memory was slightly off. It seem like an easy mistake to make.

@shanshin
Copy link
Collaborator

Implemented in 0.8.0-Beta2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type S: untriaged Status: issue reported but unprocessed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants