I think It make sense to allow a few select
using statements to each file even if they are not currently used. I’m thinking of, for example,
using System; using System.Collections.Generic; using System.Threading.Tasks
The reasoning is that it is extremely common to have methods return Task, or use one of the Linq extension methods. So even if the code is not using that today, chances are high it will tomorrow and having sonar warn about these using statements just adds noise.
There is also the case that we have a lot of common code in one of our own core namespaces (e.g.
using OurStuff.Common) and by having that include statement there in the file, it makes all those classes immediately discoverable by intellisense. This encourages code re-use and avoids people re-inventing the wheel.
My suggestion is to allow us to add using statements that sonar should allow even if they aren’t currently used in that file.