Customize External Roslyn Rules Imported to SonarQube


(PeterQuicken) #1

Is there any way to customize the external rules?

I want the generic rosyln rule sets, but would like to omit a single check: “Missing XML comment for publicly visible type or member XXX” - our folks do not necessary want to comment each line… nor create “unnecessary derpy tests” for each XML field - especially for data access layer classes.

As an example, for a class representing a particular table in an application…

public class EventCatalog : BaseEntity
{
    public int EventCatalogId { get; set; }
    public System.Guid EventCatalogGuid { get; set; }
    public string BusinessDescription { get; set; }
    public string AuthenticationType { get; set; }
    public string Username { get; set; }
    public string PasswordEncrypted { get; set; }
    public int CacheableExpireMs { get; set; }
    public string FilterTemplateJson { get; set; }
    public bool IsWritable { get; set; }
    public bool IsReplayable { get; set; }
    public bool IsDisabled { get; set; }
}

Every property/field here returns a “missing XML comment” warn, 70+ of them across these DAL classes. In discussion with the team, our view is that hand-generating XML comments for every value here would be, in general, time-consuming and of limited code readability value, preferring more “high level” comments of the code as a whole.

It has not been the common practice of the team to create these XML comments, outside of what Swagger auto-generates for a REST application, so we’re looking for a way to disable THIS ONE rule, while maintaining all the other rosyln rules - similar to the granular control we have for other language based rule sets.


How to stop including issues detected by external rules engines
(Colin Mueller) #2

Peter,

In the future, it’s a good idea to start a new thread instead of reviving an old one. :slight_smile: I hope you don’t mind, I’ve split this off into new thread.

This isn’t exactly your question (you clearly don’t want to disable all) but this StackOverflow post should point you in the right direction of adjusting the ruleset: https://stackoverflow.com/questions/36461174/how-do-i-disable-all-roslyn-code-analyzers

Colin