Add possibility to have exceptions to rule S1128 (unused using statements)

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.

Hello @Isaks

Thanks a lot for your suggestion. Looks like a very useful idea. I have created an issue on github where you can track the progress. Unfortunately, I cannot provide an ETA for the implementation.

All the best,
Čaba

That’s great news. Thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.