-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Missing coverage for logical lines split on multiple lines #270
Comments
I've noticed the same issue–I'm trying to keep my code readable and nicely formatted but tarpaulin does not like it. On the other hand, it doesn't make a ton of sense to count a statement like that as multiple lines for the purposes of coverage. I wonder if a simple-ish (maybe not so simple) solution would be to min-ify the code before measuring coverage? e.g.:
I would maybe use the minified version for the purpose of computing coverage percentage, but opinions might vary there. |
@jamestwebber In static analysis there is a concept of "logical line of code", as opposed to the physical source line of code. The latter is simply what is present in the file, whereas the logical one measures the number of executable statements. You can see some examples on Wikipedia; they are in C but they easily translate to Rust: I suppose Tarpaulin could adopt a similar approach. It's very frequently used by static analysis tools. |
So no movement on this? The majority of my new lib has multi line statements because:
Is just so much more readable than the one-line marathon. (Especially when you’re working in vim) Edited for real world example |
No movement of this, I'm trying to figure out an issue on selecting the right lines for breakpoints that solves this. Though currently I've only managed to do trial and error switching between multiple potential breakpoints and finding there is a correct solution and an incorrect solution. Need to figure out how to do this analytically and change tarpaulin to match that behaviour |
This happens for me. The project source code is at https://gitlab.com/pastebinrun/pastebinrun. Somehow |
Hmm I'd have to see how concat is implemented, if it emits no runtime instructions it should probably be filtered out of results.. |
Also is concat needed, I think if you remove it and the comma at the end of each arg it's a valid multiline string in rust (though I might be getting confused with C++ |
It's not needed, but it's going to be a ridiculously long string without it. All what I cannot have newlines in content-security-policy either (this is a HTTP header, cannot really have newlines in those). |
I think I have the same issue at this report: |
FYI, |
Similar, with a plain multi-line assignment: The full report with the source code: https://coveralls.io/builds/28315588/source?filename=src/sounddat.rs#L58 |
I've popped the issue on the new mega issue for all missing coverage etc so I'll close this one in favour of that one #351 |
System: Linux laptop 5.3.5-arch1-1-ARCH #1 SMP PREEMPT Mon Oct 7 19:03:08 UTC 2019 x86_64 GNU/Linux
Rust version: rustc 1.38.0 (625451e37 2019-09-23)
cargo-tarpaulin version: 0.9.0
It seems that Tarpaulin has the most trouble when logical lines are split across multiple lines.
I have a few examples of this behavior. I maintain rubik/orizuru, and I'm referring to the code at commit https://github.com/rubik/orizuru/tree/6a569c574137549af0d2c9148be694e2254c175c.
It's easier to see Tarpaulin's output on Coveralls, but I'll attach the raw output at the bottom of this post. On Coveralls, we can see that lines 32, 122, 126, 127, 130, 132, 133, 150, 165 of
src/consumer.rs
are marked as uncovered but they are obviously covered. Insrc/gc.rs
, the same thing is true for line 36, while on the other hand line 37 is wrongly marked as covered, when it should be line 38.Here is the raw output from
cargo tarpaulin -v --ignore-tests
:The text was updated successfully, but these errors were encountered: