On Automatic Coding Standards · 17 April, 07:44 AM
At work, we finally reached the point where we decided we needed coding standards. It’s a small development team; even though the code base is around 13 years old, up until I joined the company 2 years ago, there have been only about 10 developers that have ever worked on the code, and the current development team consists of 8 people. Still, the code base has gotten large enough, and the 8 people involved have enough stylistic differences that the code can be annoying to read.
I looked into StyleCop as a way of getting people used to the new system. It does have an extensive list of rules, but the problem I have with StyleCop is twofold:
- It’s opinionated software, which isn’t a bad thing… unless its opinions don’t match yours. It seems that you can write plugins, but for most of these rules, I don’t see why I should need to write code. Why can’t the identifier naming rules just be enforced with a regex? For instance, public const or readonly fields, IMO, should be named using something like “[A-Z][A-Z_]+”. I shouldn’t need to write code to enforce that rule and basically any other naming rule, opinionated software or not.
- StyleCop doesn’t go far enough – why nag me about the rules when you can just fix the code? My feeling is that if it can be enforced with Visual Studio auto-format, there’s no point having a rule, you just hit CTRL+K CTRL+D and it’s done. Given that even Visual Studio’s anemic refactorings support renaming fields and methods, it seems like you could enforce at least half of the default StyleCop rules automatically. I suppose I’m asking for more than a cop in this case, more like martial law. I’m told that ReSharper has an addon to do just that, and in spite of my earlier criticism of ReSharper, that does make that product more attractive.
— Gordon Weakliem
Comment
Commenting is closed for this article.
Hi,
you could take a look at StyleCop for ReSharper: http://stylecopforresharper.codeplex.com/ it should solve your issues with point 2)
/Howard
— Howard van Rooijen · Apr 26, 07:15 AM · #