Article 1YK6W CodeSOD: Work Items Incomplete

CodeSOD: Work Items Incomplete

by
Remy Porter
from The Daily WTF on (#1YK6W)

Owen J picked up a ticket complaining that users were not seeing all of their work items. Now, these particular "work items" weren't merely project tasks, but vital for regulatory compliance. We're talking the kinds of regulations that have the words "criminal penalties" attached to them.

What made it even more odd was that only one user was complaining. The user knew it was odd, their ticket even said, "Other people in my department aren't having this issue, so maybe it's something with my account?" Owen quickly eliminated their account as a likely source of the problem, but Owen also couldn't duplicate the bug in test.

A quick check showed him that the big difference between test and production was the number of work items. With a few experiments, Owen was able to trigger an infinite loop, when the number was very low. He dove into the code.

 var fullList = _complianceBL.GetRegulatoryNotificationWorkItems(_sessionGuid).ToList().ToObservableCollection(); Workitems = new ObservableCollection<RegulatoryNotificationWorkItem>(); for (int i = 0; i < fullList.Count; i += fullList.Count/35) // Get the FIRST 30 items for TEST { Workitems.Add(fullList.Skip(i).FirstOrDefault()); } Workitems.ToList().ForEach(wi => wi.Customer = new Customer(wi.CustomerID, this));

One of the senior devs had wanted to check something in the app, and wanted only a small pile of items for the test, so they wrote this block. Then, they checked it in. Then, when organizing the next code review, they saw they were responsible for the change, so they assumed it must be good.

otter-icon.png [Advertisement] Otter enables DevOps best practices by providing a visual, dynamic, and intuitive UI that shows, at-a-glance, the configuration state of all your servers. Find out more and download today! TheDailyWtf?d=yIl2AUoC8zAf7rKK4IrvtU
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments