Once food is contaminated cooking will not help. It isn't just the bacteria but the toxins they produce that cause problems. Washing won't help after the toxins are present.
In other words, if you have a seriously dented can, swollen can of food, or a jar of food that the seal has been comprimised, etc., just toss it out. Don't bother washing it. Don't bother cooking it. Don't bother to put it in the microwave. None of those will help.
Shaking tells you nothing.
There are reasons they put dates for use on food. So, use the food by the date on it or toss it. Simple concept. But this is a separate issue from dented cans.
If you have cans or packages of food that are close to but not past the expiration dates simply use those for camping or just use 'em at home. As was stated above, survivalist rations are made for long term storage but even these have use by dates.
Packages, cans, and bottles that intact should be OK, obviously, but they still have a limited shelf life. Again, these are two separate issues.
Survival rations are a bet that something severe is going to happen. However, I'll bet that the vast majority of rations get tossed. Very little food is available with an extremely long shelf life. Here's a tip -- simply rotate what's in your pantry as grocery stores rotate what's on their shelves. You'll save money and cut waste, too, and still have rations for "just in case."
So, generally speaking, if anyone buys what they need and not a whole lot more, you won't end up throwing away what you couldn't use. You'll waste less and save more. It's even more environmentally sensible.
As always, fresh food is better every time, plain and simple.