Requirements change all the time. A lot of the ideology and holy wars that happen in the Git processes camps arise from different ideas about how source control should be used to represent these changes. Which commit changed which line of code, and to what end? But what if your source control history is messy, unclear, or… you’re just not using source control?

For example, let’s say you’re our Anonymous submitter, and find the following block of code. Once upon a time, this block of code enforced some mildly complicated rules about what dates were valid to pick for a dashboard display.

Can you tell which line of code was in a reaction to a radically changed requirement?

function validateDashboardDateRanges (dashboard){
    return true; 
    if(dashboard.currentDateRange && dashboard.currentDateRange.absoluteEndDate && dashboard.currentDateRange.absoluteStartDate) {
        if(!isDateRangeCorrectLength(dashboard.currentDateRange.absoluteStartDate, dashboard.currentDateRange.absoluteEndDate)){
            return false;
        }
    }
    if(dashboard.containers){
        for(var c = 0; c < dashboard.containers.length; c++){
            var container = dashboard.containers[c];
            for(var i = 0; i < container.widgets.length; i++){
                if(container.widgets[i].settings){
                    if(container.widgets[i].settings.customDateRange){
                        if(container.widgets[i].settings.dateRange.relativeDate){
                            if (container.widgets[i].settings.dateRange.relativeDate === '-1y'){
                                return false;
                            }
                        } else if (!isDateRangeCorrectLength(container.widgets[i].settings.dateRange.absoluteStartDate, container.widgets[i].settings.dateRange.absoluteEndDate)){
                            return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!