logoalt Hacker News

Leherenn04/23/20251 replyview on HN

My only issue with defensive codding is that often it doesn't play nice with code coverage requirements. I've been in situations where I would like to add defensive coding just in case, but then the PR doesn't pass the coverage checks. The best is when you can ensure via th compiler (e.g. via the type system) that a case is impossible, but C++ (in my case) isn't perfect for this.


Replies

mezyt04/24/2025

Code coverage tools allow to pragma the defensive code which will appear reasonable to most reviewers ?