The pullchain probably won't cause an incident, but it would likely work itself loose after several on-off cycles. Then being loose may cause a splice inside the box to break, and so on, to create a hazardous condition.

Oh, you've likely seen wiring done so bad that you could accuse the installer of attempted arson, but this shed switch kludge would be classified as "mildly hazardous". Even if it has odds of 1 to 10,000 of causing an incident in a year, that would still mean that if that kludge existed in each of the, say, 100 million dwellings nationwide, you'd have 10,000 incidents every year. Which is way too many, so the code is written to get that down to just a few incidents a year. Or none at all.