WiseTechGlobal / WTG.Analyzers

Analyzers from WiseTech Global to enforce our styles, behaviours, and prevent common mistakes.
Other
15 stars 3 forks source link

Relax WTG3103 for comma-separated items. #188

Closed yaakov-h closed 1 year ago

yaakov-h commented 1 year ago

Closes #181.

I'm not quite sure if this is the best way to do this, but it appears to work.

I might have been a little over-zealous by making sure that the comma is on the same line as the neighboring comma-separated item, do you think that's necessary?

brian-reichle commented 1 year ago

I might have been a little over-zealous by making sure that the comma is on the same line as the neighboring comma-separated item, do you think that's necessary?

This essentially comes down to "do we allow the comma between items to be on a line of it's own?" I can't think of a valid reason why you would want to have the comma on a line of it's own, but I also cannot think of a valid reason why you would treat it any different when it is on it's own line.

On balance, I would probably leave out the line number check for two reasons:

  1. It's getting into code formatting and I think such responsibilities should be in separate rules. (in this case, I think there is already a StyleCop rule that would kick in).
  2. skipping the check means less work for the rule to perform.
yaakov-h commented 1 year ago

I came to the same conclusion overnight, the GetLocation() and GetLineSpan() functions gave me the impression they might be a little bit expensive.

I've pushed updates and created WI00546535 for tracking.