There are a lot of writing flaws in this episode as other writers have pointed out. However, the chemistry between Griffith and Knotts outweigh the plot flaws.
There's some real heart in this as Barney tries to get Andy to apply for the opening in the Raleigh police force not knowing its HIS job that's opening. Knowing what may be coming for Barney, Andy reminds him that his job in Mayberry is still open and he'd love to have him back. Then its old times as usual as Andy sets up a trap for the family Barney is rooming with and manages to catch them red-handed while throwing the credit to Barney.