DotNetAnalyzers / StyleCopAnalyzers

An implementation of StyleCop rules using the .NET Compiler Platform
MIT License
2.61k stars 506 forks source link

SA1015 false positive on object initializer #3856

Closed n0099 closed 1 month ago

n0099 commented 1 month ago

https://github.com/n0099/open-tbm/commit/b29fea0747d7ce3bce5e2000429fd4a417d4655e#diff-ca28356cfa73fff3341e8571881b0401158b49858f07d83d30e1ece640b15fe2R19

protected override Lazy<Dictionary<Type, AddSplitRevisionsDelegate>>
    AddSplitRevisionsDelegatesKeyByEntityType =>
    _addSplitRevisionsDelegatesKeyByEntityType ??= new(() => new()
    {
        {typeof(ReplyRevision.SplitFloor), AddSplitRevisions<ReplyRevision.SplitFloor>},
        // SA1015 Closing generic bracket should be followed by a space              ^
        {typeof(ReplyRevision.SplitSubReplyCount), AddSplitRevisions<ReplyRevision.SplitSubReplyCount>},
        // SA1015 Closing generic bracket should be followed by a space                              ^
        {typeof(ReplyRevision.SplitAgreeCount), AddSplitRevisions<ReplyRevision.SplitAgreeCount>}
        // SA1015 Closing generic bracket should be followed by a space                        ^
    });
bjornhellander commented 1 month ago

Just to clarify: Normally, those three lines would also get a SA1012 since they don't have a space after the opening brace and a SA1013 since they don't have a space before the closing brace. I assume that you have intentionally turned both of them off, since you only mention SA1015?

n0099 commented 1 month ago

I assume that you have intentionally turned both of them off

Yes: https://github.com/n0099/open-tbm/commit/b2910ff273366680c028dbef3f3065dfb58abc3a#diff-dee8b4f6b469005cc91d8562bba59ac8c3b8b151d08f85ed8f8b613ace4132ecR23

bjornhellander commented 1 month ago

Ok, well I agree with you. I also think this is a bug.