A BB gun is fully capable of injuring a human or animal. Similarly, a .22 is more likely to injure an animal than to kill it, unless the animal is hit in a vital organ, and is fully capable of killing a human. If you are a good enough shot, a .22 will kill large game, but it's dangerous for the shooter and the animal. A .22 is fully capable of penetrating and exiting an animal's body and going on to strike whatever is beyond it. Be that a tree, a house, another animal, or a person. If a neighbor's shed is that close to the coop, it is NOT SAFE to discharge a firearm of ANY kind, particularly toward a tree, where there is no guarantee of a backdrop capable of stopping the bullet. If this is within city limits, discharging a firearm is generally highly illegal. Please be very aware of what is beyond your target, before you pull the trigger, whether you are using a BB gun, an air gun, or a hunting rifle, and be aware that a bullet striking a solid surface is very likely to ricochet in any direction, including straight back at you. I've personally seen someone struck by the bullet they fired, after it hit a piece of metal and ricocheted back at them.
Firearm safety is vital. Nobody wants to shoot something they didn't mean to hit.