Hi,
Just curious how the StyleCopAnalyzers specific versus the original StyleCop rules are debated and assessed? Its possible I am missing the obvious but I wonder how SA1413 actually improves maintainability? I feel it makes code confusing leaving a developer to wonder if someone possibly removed a line in error? With the trailing comma removed it requires a more deliberate change.
All of these rules are implemented because of subjective reason. The reasons for implementing this rule can be seen in this issue: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1121.
I did find that thread but it does not explain how the rule assists in maintainability. I can discount the weight of my opinion, I am only a grateful user who doesn't contribute but this rule the first which I can honestly say I didn't see merit in but actually thought it promoted the opposite. For even the stylistic rules that are subjective, I have always been able to justify them on the premise that consistency and uniformity is important.
The real purpose of my inquiry was simply to learn how the rules are voted in and discussed. My original post describes how I see this rule to be counter productive and promoting of confusion.
@jcasale Note that this is a maintainability rule as opposed to a readability rule. The advantages of including the comma have to do with the work required to make a change to the item falling at the end of a list (removing it, adding to it, or reordering it). With SA1413 in place, these changes are slightly less work for the developer on average. They are also less work for a reviewer because you aren't including lines in your diff just for adding a comma where one wasn't before.
I voted in favor of the rule for the following combination of reasons:
We don't have a formal process defined/documented for new rules. StyleCop is opinionated on a subject matter that the compiler really doesn't care about, so typically we try to weigh the following to determine what/if opinion we'll have:
@sharwell Thanks for the detailed reply.
Sam recommended that I turn off this rule if I don't like it. I think your rational is backwards. At this stage in the product's maturity, you should be telling the people who want this new rule to turn it on. Jamming something this trivial this down our throats when we've invested weeks if not months of man-hours to get compliant just adds aggravation to my day and I don't see the advantage.
@DRAirey1 We do have a high bar for several aspects of new rules. In particular:
:bulb: In general we prefer to not add a new rule unless these items can be met and the rule enabled by default.
The time required to update a codebase for compliance with the new rule is minimal, but the new rule may also be disabled either due to personal preference or for any other reason.
Just to weigh in my opinion, I would prefer to see this rule disabled by default, and the opposite rule suggested in #1121 should be implemented and enabled by default. Primarily this is to be consistent with tools like ReSharper which flags trailing commas as redundant and suggests they be removed.
Additionally, I think this rule only improves edit-ability slightly (and tools like ReSharper mitigate most of the complaints), whilst readability is impacted (albeit only slightly as well). I think its generally accepted that code is read many more times than its written, so we shouldn't promote write-ability at the sake of readability.
I've been following this project for some time, but not dipped my toes into actually helping yet. I would be happy to start here if there are no objections, although I may need a few pointers to get started :)
@berkeleybross At this point I would not expect the default behavior of this rule to change. A specific proposal to add an option (with values require/allow/omit like seen in #2050) might be entertained as long as the default is require. If you are interested in this, the best way to start would be with an issue proposing the new option.
Chipping in here as I was very surprised to discover this rule existed. A trailing comma in a list is a syntactic abberation that I would expect most developers (and English language speakers) to object to and actively remove. I implore you to reconsider it.
"but the new rule may also be disabled either due to personal preference or for any other reason."
I don't know if others see this as black-and-white as I do, but the minute you disable any of the rules for 'personal' reasons, you open up a can-of-worms. Why should the lead developer get to chose what rules he likes and doesn't like? Let's have a committee where we'll discuss which rules we're going to adopt as our standard. Wait, the build engineering group also has a list of preferred rules, let's have a meeting to discuss which ones we're both going to use.
FWIW, If I allow my developers to select personal preferences, there's not a whole lot of benefit to using StyleCop if I've got several 'standards' floating around the shop.
We really hated this rule.
Most helpful comment
We really hated this rule.