We study the luminosity function and formation rate of long gamma-ray bursts ( GRBs ) by using a maximum likelihood method . This is the first time this method is applied to a well-defined sample of GRBs that is complete in redshift . The sample is composed of 99 bursts detected by the Swift satellite , 81 of them with measured redshift and luminosity for a completeness level of 82 \% . We confirm that a strong redshift evolution in luminosity ( with an evolution index of \delta = 2.22 ^ { +0.32 } _ { -0.31 } ) or in density ( \delta = 1.92 ^ { +0.20 } _ { -0.21 } ) is needed in order to reproduce the observations well . But since the predicted redshift and luminosity distributions in the two scenarios are very similar , it is difficult to distinguish between these two kinds of evolutions only on the basis of the current sample . Furthermore , we also consider an empirical density case in which the GRB rate density is directly described as a broken power-law function and the luminosity function is taken to be non-evolving . In this case , we find that the GRB formation rate rises like ( 1 + z ) ^ { 3.85 ^ { +0.48 } _ { -0.45 } } for z \la 2 and is proportional to ( 1 + z ) ^ { -1.07 ^ { +0.98 } _ { -1.12 } } for z \ga 2 . The local GRB rate is 1.49 ^ { +0.63 } _ { -0.64 } Gpc ^ { -3 } yr ^ { -1 } . The GRB rate may be consistent with the cosmic star formation rate ( SFR ) at z \la 2 , but shows an enhancement compared to the SFR at z \ga 2 .