It looks OK to code. If you're concerned about that, I suggest you never look behind the drywall. People risk cutting through wires all the time. It's not so much that you're supposed to move wires away from the drywall, it's that you're not supposed to be cutting through drywall when you don't know if there's a wire back there. At some point of course you have to take a risk and at least drill a hole in the wall. Doing this as far from a stud as possible means that if you do touch a wire, it will have a little more room to jiggle, rather than getting cut.
So you'd drill a big enough hole in order to get a right-angle drill in there? And I was thinking that instead of holes at different heights, I'd just cut across the top of the wall, and two spots on the ceiling. ??
No, I cut a big enough hole to get my hand and drill inside.
It is easier to repair a 12 x 12 hole than it is to to repair a small hole used to notch the joist with.
At the junction of the wall and ceiling, a hole needs to be cut in the wall to be able to drill upwards and a hole in the ceiling to drill the joist and get to the wire.
Yes I am a Pirate, 200 years too late. "Jimmy Buffett"