I've been repairing guns for many years and often get guns that were "treated" to WD-40. The stuff, after a several months or years, gums up trigger mechanisms and leaves a sticky coating on gun exteriors as well. I haven't seen it turn to varnish, but won't use it on my guns.
It's also been known to kill primers when sprayed into rifle bolts, then the guns stored standing up. Upon hunting, WD-40 (and other fine oils) can drip from the firing pin hole onto primers, seep around them, and often kill them.
Oils should be used sparingly, especially on rifles like Win 94s and fine double-barreled shotguns whose buttstocks are open from the action. Used to excess, oil will seep into the buttstock wood, turning it dark around the metal contacts and actually rot it out. I've repaired many that have been damaged that way, usually by routing out the soft wood and replacing it with Brownell's Acraglas, along with pins or screws. If done right, the repair is not readily apparent from the outside.