What is the cost of a bug?

All software has bugs, but each has a different cost depending on when and where it's found.

In production

If a bug was found in production, it was probably found by a user, will time to replicate, diagnose and fix, and could have caused some reputational or financial damage.

You'd need to create a ticket and schedule the work, meaning you're not working on something else.

Cost: High

In a pre-production environment

It's likely found by a test analyst or product owner but hidden from the end users and customers.

It will still take time to replicate, diagnose and fix, and you'd still need to create a ticket and schedule the work, as well as the bug potentially blocking releases to production until it's resolved.

Cost: High

In a CI pipeline

This is likely to be a static analysis or a test failure. It should be quicker to fix though it will need to be done quickly or reverted if you're doing trunk-based development to unblock other Developers.

If you're doing code reviews, you'll need to ensure that the pipeline passes before the review and continues to pass after making any changes.

Cost: Medium

Locally

If an automated check fails in CI, why not run it locally before you commit and push the change?

If it's a coding standards issue or static analysis failure, you could configure your text editor or IDE to show you issues in real time. Then they can be fixed immediately and not even committed and pushed to a CI pipeline.

If you were working in a pair or mob, could someone else have spotted the issue and suggested a fix?

Cost: Low

The sooner you can find a bug, the less time and cheaper it is to fix, and we can use tools like automated tests and static analysis to help us write fewer bugs and to fix them sooner and faster.