This function is defined everywhere, its critical numbers are where f'(x)=0.
f'(x)=2*(x+2)*(x-1) + (x+2)^2 =
(x+2)*(2x-2+x+2) = (x+2)*(3x).
This is =0 at x=-2 and x=0. Also f'(x) is negative for x in (-2, 0) and positive in `(-oo, -2) uuu (0, +oo).` The function f is decreases and increases correspondently. Therefore x=-2 is the local maximum and x=0 is a local minimum.