CodeSOD: Getting Reported

This post was originally published on this site

The Daily WTF

Monica sends us a code snippet that comes from her organization’s home-brewed reporting engine. She writes:

I have always found that “Homebrew Reporting Engines” are always full of WTF material. For some reason, coded reports are a “good place to learn the codebase” for junior engineers and usually have deadline of “just get that done”.

In this case, a Java web application needs to load a list of reports. For some reason, the list is stored in the web.xml file, even though all the data about the reports is actually stored in the database. That’s a nuisance, but this is the code which fetches it:

Boolean bool = Boolean.valueOf(!Toolkit.isEmpty(list = WebConfigInitializer.WebConfig.instance().getConfigValues(“Reports”, hs))); request.setAttribute(“multipleReports”, bool); if (bool.booleanValue()) { ArrayList<RepDefinitionBean> arrayList = new ArrayList(); for (Iterator<String> iterator = list.iterator(); iterator.hasNext();) { if ((reportList = ReportListApp.loadByName(str = iterator.next())) != null && ( reportDefinition = ReportDefinitionApp.loadReportDefinition(reportList.getReportNo())) != null) { RepDefinitionBean repDefinitionBean =

To read the full article click on the 'post' link at the top.