Looks like the unit was removed from a previous installation, nailed to the joist and connected to the romex - free air splice I guess you might call it. Almost looks like that upper nail goes right through the romex doesn't it? Guess they had to secure it within 12" of the box somehow. Do have to wonder what they have hanging from the lampholder by that wire - side of beef??