Although it may not seem obvious at first sight, it is coherent with control theory (see, e.g., here http://www.emba.uvm.edu/~gmirchan/classes/EE275/Handouts_Ed4/Ch07(4e)Handouts/Ch7(4)Handouts_4e.pdf). The code implements a "Backward Rectangular Integrator" or "First order method", as stated by the comments.
From a theoretical point of view, let
ui(k) be the integral term and
e(k) the rate error at instant
k, respectively, (represent by
rates_err in the code), let
E(z) be their z transforms, if implemented as you mentioned (the recursive definition that you called a "weird way"), we can apply the z transform to the formula
ui(k) = ui(k-1) + ki * dt * e(k)
to find out its transfer function
Ui(z)/E(z) = ki * dt * / (1 - z^(-1))
and that's the same expression that is presented in the document that I mentioned.