“He came in in a state of shock.” This writing behavior looks weird and feels weird, yet it is actually perfectly acceptable to repeat words in this fashion. If you read a lot of books you will often see words doubled up by seasoned authors who care not that it may look a bit silly repeating themselves on paper. However, you will notice, if you use MS Word, that the grammar checker highlights such behavior as an error (repeated word). Personally, where possible, I avoid doubling up words in sentences because I think it looks inelegant and unprofessional. So, rather than be lazy, always search for a better way to phrase your sentence. See the examples below for ideas:
“When she came to my house I showed her her message.”
This sentence could easily be rephrased as, “She came over to my house and I showed her the message she had sent earlier.”
“I had had to go to the shops that Tuesday morning.”
This can easily be rephrased as,“I had gone to the shops that Tuesday morning.”
“We will discuss this this coming weekend.”
Replace the first “this” with a pronoun; “We will discuss it this weekend.” Or a noun; “We will discuss the matter at the weekend.”
“What it is is a complete mess.”
This is a poor way to start a sentence, anyway, so rephrase this as, “It is a complete mess…”
“He came in in a state of shock.”
Replace the prepositional phrase with a simple verb, as follows, “He entered in a state of shock”.
On occasion, an immediate repetition of a word, separated by punctuation, is appropriate for emphatic effect, for example, “I am far, far away from home.” So, the rule is, repetition of a word in a sentence that makes grammatical sense isn’t wrong, but there is actually no reason for this to occur if you put the extra effort in and revise your sentences accordingly.