I'll use WD40, but mostly by first spraying it on a patch and *then* apply it to a gun. Back before we had the clean-burning gunpowders of today, I'd spray it directly into a Govt. model to flush out grunge. The issue of hardening and dirt buildup didn't apply, since I disassembled the pistol for thorough cleaning after the shooting session.
It is wonderful stuff if you've had your gun out in the rain. "WD" stands for "Water Dispersant" or something like that, and the 40 refers to the 40th formula tried by the inventor. It will make moisture bead up and run off metal--a lifesaver out at a huntcamp.
But for sure, keep WD40 or any other cleaner/lubricant away from scope lenses and away from ammunition. Any good oil will "creep" and find its way into all manner of "wrong" places.
If only folks took care of guns and cars the way pilot/owners take care of airplanes...