Kevin L saw the program crash with a null pointer exception. This lead to digging through stack traces, logs, and eventually the commit history to figure out who was responsible.

Gauze Pad

The code itself is a simple “string padding” function, the sort of thing that when people screw it up, you just have to wonder why. This variation on that theme, however, gives us that rare treat: an accurate comment that describes the function.

// there is a much better way to do this.... 
    public static String padRegistrationNumber(String registrationNumber) {
        if (registrationNumber.length() == 11) {
            return " " + registrationNumber;
        }
        if (registrationNumber.length() == 10) {
            return "  " + registrationNumber;
        }
        if (registrationNumber.length() == 9) {
            return "   " + registrationNumber;
        }
        if (registrationNumber.length() == 8) {
            return "    " + registrationNumber;
        }
        if (registrationNumber.length() == 7) {
            return "     " + registrationNumber;
        }
        if (registrationNumber.length() == 6) {
            return "      " + registrationNumber;
        }
        if (registrationNumber.length() == 5) {
            return "       " + registrationNumber;
        }
        if (registrationNumber.length() == 4) {
            return "        " + registrationNumber;
        }
        if (registrationNumber.length() == 3) {
            return "         " + registrationNumber;
        }
        if (registrationNumber.length() == 2) {
            return "          " + registrationNumber;
        }
        if (registrationNumber.length() == 1) {
            return "           " + registrationNumber;
        }
        return registrationNumber;
    }

Note: it’s an accurate comment. It’s still not a useful comment- this function's crapfulness is entirely self-documenting.

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