La Línea de la Concepción, the border town next to Gibraltar. Not a very nice place to live (Gibraltar is awesome and super safe though, but expensive).
On the other hand, there are a bunch of nice places around the area that are pretty safe and beautiful (Guadiaro, Sabinillas, Manilva, or larger/more expensive you have Sotogrande, Estepona)
But yeah, La Linea is an absolute dump, wouldn't be caught living there (the smells, the people, the pollution, horrible!)
Yeah, you're absolutely right. If you're working in Gibraltar and can't afford living there or want to live in Spain I would definitely recommend some of those or at least Santa Margarita. You can get a villa in Spain for the same price as a small one bedroom apartment in Gibraltar.