There is a concept called “technical failure”, which means that the rep you just did is no longer performed with the same technique as the first few reps. If this occurs twice in a row, you should finish the set. For example, when I do a close-grip chin-up and the tempo for my programme requires a 4-second lowering or eccentric phase, if I can’t get my chin above the bar, can’t lower myself slowly or don’t straighten my arms out at the end and this happens twice in a row, that set is finished and I record in my logbook (you do have a logbook, right?) the number of reps I did.
Cheating can be dangerous, like bouncing hard out of the bottom of a squat or bench press, or rounding your back on a deadlift… and this is of course terrible. However, cheating isn’t always dangerous for some exercises, but I still don’t recommend it. If I kick or swing myself up on a chin-up, I may improve at the swinging technique, but I am not making my lats or biceps much stronger at all. Finally, when you cheat, you can’t really gauge how much you’ve cheated and it is therefore difficult to measure your progress.