Hi. Thanks for this interesting idea. It makes a lot of sense for Legacy Code bases!
I remember doing something similar in a previous team. We used to mark sections of the code that were very performance sensitive with an @Crititcal annotation (any kind of in-code meta-information would do). This way, we knew we should apply readability first coding convention on all the code base, except on these few sections, where we had other coding conventions, targeted towards maximum performance.
Do you think there is a way to mark a piece of code as @NoNeedToTest directly from within the code? This way, when a developers changes the code, he would see whether or not he should keep this annotation or not? It might be easy to forget to re-add a piece of code to the coverage analysis when it is changed.
I work on a lot of PHP projects and I really like the way PHPUnit handles this. You can exclude code from the coverage analysis with annotations. You basically flag classes, methods or functions with @codeCoverageIgnore and can even wrap blocks of code with @codeCoverageIgnoreStart and @codeCoverageIgnoreEnd. That way, developers directly see whether the code they are working on is covered.
I know that Istanbul and JaCoCo have similar annotations. If your language/tools don't, you're left with conventions and that often doesn't work so well. Humans are humans, after all.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi. Thanks for this interesting idea. It makes a lot of sense for Legacy Code bases!
I remember doing something similar in a previous team. We used to mark sections of the code that were very performance sensitive with an @Crititcal annotation (any kind of in-code meta-information would do). This way, we knew we should apply readability first coding convention on all the code base, except on these few sections, where we had other coding conventions, targeted towards maximum performance.
Do you think there is a way to mark a piece of code as @NoNeedToTest directly from within the code? This way, when a developers changes the code, he would see whether or not he should keep this annotation or not? It might be easy to forget to re-add a piece of code to the coverage analysis when it is changed.
Thanks
I work on a lot of PHP projects and I really like the way PHPUnit handles this. You can exclude code from the coverage analysis with annotations. You basically flag classes, methods or functions with
@codeCoverageIgnore
and can even wrap blocks of code with@codeCoverageIgnoreStart
and@codeCoverageIgnoreEnd
. That way, developers directly see whether the code they are working on is covered.I know that Istanbul and JaCoCo have similar annotations. If your language/tools don't, you're left with conventions and that often doesn't work so well. Humans are humans, after all.