In this paper, we investigate the Kundu–Eckhaus equation with variable coefficients, which describes the propagation of the ultra-short femtosecond pulses in an optical fiber. By virtue of the generalized Darboux transformation, the first- and second-order rogue-wave solutions are derived under certain variable-coefficient constraints. Representing the group velocity dispersion, nonlinearity parameter and nonlinear refractive index, effects of the nonlinear dispersion on the rogue waves are graphically discussed: Shape of the first-order rogue wave and features of the second-order rogue waves are displayed when the nonlinear dispersion is a constant. With the choice of the nonlinear dispersion as a linear function, widths of the first- and second-order rogue waves change with the amplitudes invariant. Oscillating behaviors of the first- and second-order rogue waves are also observed with the nonlinear dispersion as a trigonometric function.