Hi,
Would it be possible to have a global configuration option to ignore trivial code, similar to Cobertura's IgnoreTrivial?
In particular, I'd like to ignore properties with standard getters/setters without having to annotate each of them with ExcludeFromCodeCoverage or another attribute.
The reservation I have with this request is that what constitutes trivial code is often subjective. There's no one size fits all and that opens the door to lots of over-specific requests which will lead to adding yet more options that the user has to wade through
That makes sense, I do agree that "trivial code" is too general and subjective.
I think that a more specific option to ignore auto-implemented properties would be useful for code with lots of model classes (value objects / DTOs), and fairly uncontroversial in that auto-implemented properties qualify as trivial code.
@ob-stripe I usually exclude classes or modules, I'd like to understand the reason to remove getter/setter/ctor, maybe performance or noise on reports?
@MarcoRossignoli Noise on reports would be the main motivation. Our tests don't cover every single auto-implemented property, and it makes it more difficult to go through coverage reports to identify code that _should_ be covered.
Excluding entire classes is not a good fit for us because some properties have custom accessors and we do want to ensure those are tested.
I don't know Cobertura so well(sorry) https://github.com/cobertura/cobertura/blob/9de3fb15edd73141c8b6887f07840ec3250a62d1/CHANGELOG.md#version-200 --ignoreTrivial do the same things of global config you pointed out or not?Should be better if report tool excludes noise on generation, I'm close to @tonerdo(and yours) feeling, it's difficult find a generic definition of trivial code, you said auto-implement props, but ctors etc...I don't have a very strong opinion but FWIW I'd avoid.
To clarify, what I meant is that I'd prefer something like --exclude-auto-properties over --exclude-trivial-code: the latter is ambiguous about what it does, while the former seems pretty clear to me.
It would be even stricter than Cobertura's ignoreTrivial option in that it would only exclude gets and sets without a body. Constructors would be entirely out of scope.
Ultimately though, this is just a minor inconvenience to us. I thought that others could benefit from having this feature, but if the maintainers of this great tool and the community disagree, I won't be offended if this request is denied.
I agree with you "this great tool" and @tonerdo has the final say!
See also issue #81
I assume that simply ignoring CompilerGeneratedAttribute is too broad? I'm thinking the answer is yes, but I haven't dug into all the various permutations in the IL.
@iamwyza CompilerGeneratedAttribute is not correct...async/await state machine has got this attribute and inside there is "user code" to instrument.
@tonerdo we could close this in favour of #81
Tracked in #81
Most helpful comment
To clarify, what I meant is that I'd prefer something like
--exclude-auto-propertiesover--exclude-trivial-code: the latter is ambiguous about what it does, while the former seems pretty clear to me.It would be even stricter than Cobertura's
ignoreTrivialoption in that it would only excludegets andsets without a body. Constructors would be entirely out of scope.Ultimately though, this is just a minor inconvenience to us. I thought that others could benefit from having this feature, but if the maintainers of this great tool and the community disagree, I won't be offended if this request is denied.