# Processing data in the right manner in data science

From what i have learned, people say that it is more correct if i preprocess data after splitting it to train/test dataset. My questions are

1.Does it mean we detect flaws of the data + preprocess it after the splitting? if yes/no, why?

2.Is it okay if i detect flaws of the data before splitting it and then preprocess the flaws after splitting it? if it is/ no it is not, why?

Example: let's imagine we want to classify short messages (e.g. tweets). When inspecting the data we find various kinds of smileys: :-), :|, :-/... At preprocessing stage we replace all smileys found in the data with a special token like <smiley> (or something more specific).
• If the detection/replacement is done on the whole data, every occurrence of a smiley in the test set is replaced with <smiley>.