Not compliant with code requirements. The box can be set back no more than 1/4" from a noncombustive surface, flush or proud of a combustible surface. Tucking the splice in the box is not enough to contain an arc or spark .Use longer screws to mount the fixture. Keep all the connections in the box.
You really should stick to things you know instead of leading posters astray and giving incorrect advice.