CodeSOD: Attestation

Good commit messages make a codebase a lot easier to understand. In fact, maybe writing good commit messages could be everyone's New Year's Resolution. You can imagine that Kleyguerth was annoyed when browsing recent changes and saw a pair of commits: "do some stuff", followed by "fixed automated tests".

The "do some stuff" commit looked like this:

if (user) {
    //do some stuff
}

The code has been elided, but it doesn't really matter. This is TypeScript, so the check is "if user is truthy, do some things". The following commit, which "fixed automated tests", changed the code to this:

if (user && !('test' in user)) {
    //do some stuff
}

So yes, something about do some stuff broke the tests. Our intrepid developer saw failing tests and figured out how to fix them: by ensuring that the code which breaks them doesn't run if we're in testing.

And while yes, the automated tests use a user named "test" to run most of their tasks, there is no rule preventing an actual user from using "test" in their name, and since it's a simple in check, you don't have to be the alertest or astutest to see a need to protest this change, and to detest that it was ever made.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

This post originally appeared on The Daily WTF.

Leave a Reply

Your email address will not be published. Required fields are marked *