At Codecov, we understand that developers are the driving force behind our tool so we’ve committed to pushing feature releases and settings that are requested by our users. Today we’d like to introduce a new Codecov setting called Removed Code Behavior, which allows your status checks to pass in the event that the coverage of your contributions on a PR is high, even though overall coverage may go down.
This feature is particularly useful in situations where developers are refactoring or cleaning up older code. It’s common for developers to write new code to replace outdated code, but this can sometimes result in a decrease in overall project coverage. Particularly in those scenarios where developers are removing more covered code than they’re adding back as the result of a refactor. In the past, this scenario would trigger a status check failure, effectively punishing developers for improving the codebase. With this updated setting, you can specify in the codecov.yml
configuration file whether or not to pass the status check in these scenarios.
To use the Removed Code Behavior feature, you simply need to add the relevant configuration to your yaml file. For example:
coverage:
status:
project:
default:
# basic
target: auto
removed_code_behavior: fully_covered_patch
This configuration tells Codecov to pass the status check if the patch coverage is 100% and there are no unexpected changes, regardless of the impact on overall project coverage. You can also choose to not pass the check in these scenarios by setting the removed_code_behavior
value to off
.
This setting helps developers and organizations improve their codebase without worrying about unexpected status check failures. For more information on how to use this feature, you can refer to the full documentation in the Codecov docs. Once implemented, we encourage you to keep sending us your feedback to help us continually improve Codecov.