The warehouse is something most players do not pay much attention to. The purpose is to protect your rss from attack. See picture below of a warehouse level 40
If you have attacked another base and won. You have probably seen that you get some rss like food, oil , coins etc.
Your warehouse has limitations based on the level of the building. Meaning that if you try to keep as little as possible outside the volume of your warehouse size you stand to lose very little if you lose a fight. The difference between the warehouse size and the volumes of rss shown in the black rss line under your VIP, and power level is what you stand to loose. At level 40 it’s look like this.
So a tip is to balance the rss to what you have planned of tasks. Then you have your warehouse as a surplus or extra storage in case you need more for some unseen task.
All this being said. It’s very difficult to make this balance, so the second best is to just have an eye on your rss and the warehouse capacity, and perhaps keeping your shield up if you have a lot of rss outside of the storage capacity of the warehouse.