Code review comment for lp:~openerp-dev/openerp-web/trunk-bug-1011492-pan

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Looking at that code, it bothers me that the behavior seems arbitrary and lucky, it makes the error disappear but doesn't actually fix it: it's relying on the implementation behavior of min wrt `undefined`, and then relies on the inequality test wrt 0 for the definition of the axis min values.

The way I'd see to do that, _.min returns ``undefined`` if the list of values is empty, instead of pre-testing and returning some arbitrary value use [null, Infinity] as the inner min

    var record_min = _.min(record.data, function (item) {
        return item[1];
    }) || [null, Infinity];
    return record_min[1];

this ensures the second member is as big as can be, and will always correctly behave in other mins, and in comparisons with `0`.

review: Needs Fixing

« Back to merge proposal