Just installing a junction box doesn't guarantee safety. The box must be fitted properly so it's flush with the drywall. Otherwise, combustible materials\u2014like wood\u2014are exposed to potential sparks. If the junction box is recessed too far into the wall, correct the problems with an inexpensive box extension.