StyleCop

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
StyleCop
Original author(s) Microsoft
Developer(s) Andy Reeves, Chris Dahlberg
Stable release
5.0.6329.1 / April 30, 2017; 15 months ago (2017-04-30)
License Microsoft Public Licence
Website github.com/StyleCop

StyleCop is an open source static code analysis tool from Microsoft[1] that checks C# code for conformance to StyleCop's recommended coding styles and a subset of Microsoft's .NET Framework Design Guidelines. StyleCop analyses the source code, allowing it to enforce a different set of rules from FxCop (which, instead of source code, checks .NET managed code assemblies).[2][3] The rules are classified into the following categories:

  • Documentation
  • Layout
  • Maintainability
  • Naming
  • Ordering
  • Readability
  • Spacing

StyleCop includes both GUI and command-line versions of the tool. It is possible to add new rules to be applied.

StyleCop was re-released as an open-source project in April 2010 on CodePlex.

StyleCop 4.7.55 (November 10, 2016) is compatible with Visual Studio 2008, 2010, 2012, 2013, and 2015.[4] (Microsoft Visual Studio Extension)

StyleCop moved to GitHub.[when?]

StyleCop 5.0.6329.1 (April 30, 2017) works with Visual Studio 2012, 2013, 2015, and 2017.[5] (Windows Installer)

Development is stopping. A named successor is StyleCopAnalyzers, for Visual Studio 2015 and later.[citation needed]

Disadvantages[edit]

It reduces productivity, as many of its rules are controversial and superfluous.[citation needed] For example, StyleCop does not allow the following statement to compile:

if(myVar.Equals(anObject))
{
    this.doSomeWork(myVar)
}

It would state that there should be a space between the keyword "if" and the "(" symbol, so it must be refactored to the following:

////Notice the space after if
if (myVar.Equals(anObject))
{
    this.doSomeWork(myVar)
}

This is a rule imposed by the tool, not by the language, and the programmer must spend time inserting such spaces. Also, StyleCop's rules apply to all code. This can make it difficult for a programmer to quickly write code for testing functions, as these "quick test" functions must follow the strict guidelines imposed by the tool.

See also[edit]

References[edit]

  1. ^ "A Brief History Of C# Style". Retrieved 2016-07-19. 
  2. ^ Patton, Tony (June 24, 2011). "Maintain code consistency with Microsoft StyleCop". Blogs / Software Engineer. TechRepublic. Retrieved December 10, 2011. 
  3. ^ Chinery, Clive (July 30, 2009). "8 More Useful Tools for ASP.NET". ASP .Net. Server-Side Magazine. Retrieved December 10, 2011. 
  4. ^ https://stylecop.codeplex.com/ StyleCop (old CodePlex site)
  5. ^ https://marketplace.visualstudio.com/items?itemName=ChrisDahlberg.StyleCop StyleCop - Visual Studio Marketplace

External links[edit]