StyleCop rule for different bracing style instead of just disabling it?

379 views Asked by At

1st, lets be clear that bracing style is mostly taste only - that is, if a team decides on a certain taste, who am I to question that (within reason).

The problem is then when you use tools like StyleCop (btw. are there actually any other C# tools like StyleCop? I have the impression its rather singular in the C# ecosystem?)

StyleCop, by default, enforces a certain bracing style, the one in question I found is: CurlyBracketsForMultiLineStatementsMustNotShareLine, i.e. it enforces

void bla()
{
  return x;
}

instead of

void bla() {
  return x;
}

The team, however, would really like to stick to the second style.

The question I ask myself is now:

  • Can I get Stylecop to validate the other rule, instead of just disabling the rule?
  • Are we shooting ourselves in the foot by deviating from the StyleCop recommendation?
1

There are 1 answers

0
Martin Ba On BEST ANSWER

Thanks to Patrick:

The style referred to in the question is mostly K&R indentation style and there is a StyleCop issue 6693 that is closed with the message:

Closed Aug 17, 2010 at 11:17 PM by jasonall

StyleCop does not comply with the K&R style. It would be difficult to tweak the rules to partially support this style. A better option would be for a third-party dev to create an alternate K&R ruleset.

So it is simply not supported.