StyleCop C#ソースコードの分析ツール


Announcing the release of Microsoft Source Analysis for C#
http://blogs.msdn.com/sourceanalysis/archive/2008/05/23/announcing-the-release-of-microsoft-source-analysis.aspx
https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sourceanalysis
より。



Source Analysis is similar in many ways to Microsoft Code Analysis (specifically FxCop), but there are some important distinctions. FxCop performs its analysis on compiled binaries, while Source Analysis analyzes the source code directly. For this reason, Code Analysis focuses more on the design of the code, while Source Analysis focuses on layout, readability and documentation. Most of that information is stripped away during the compilation process, and thus cannot be analyzed by FxCop.



ソースコード分析は、いろいろな面でマイクロソフトのコード分析(特にFxCop)と似ているが、いくつかの重要な部分に違いがある。
FxCopコンパイル済みのバイナリを分析対象としているが、ソースコード分析はソースコードを直接分析している。つまりコード分析はコードの設計に重点を置いているのに対し、ソースコード分析はレイアウト・読みやすさ・文書化に重点を置いている。これらの情報の多くはコンパイルのプロセス中にそぎ落とされてしまうのでFxCopでは分析できないのだ。



Source Analysis comes with a set of default rules analyzers covering approximately 200 best practice rules. These rules are full compatible with the default layout settings in Visual Studio 2005 and Visual Studio 2008.

Specifically, these rules cover the following, in no particular order:



ソースコード分析には、200前後のベストプラクティスをカバーしたデフォルトのルールアナライザが付属している。これらのルールはVisual Studio2005 2008のデフォルトのレイアウト設定と完全に互換性保っている。
ルールがカバーしている範囲は以下のとおり(順不同)


  • Layout of elements, statements, expressions, and query clauses
  • Placement of curly brackets, parenthesis, square brackets, etc
  • Spacing around keywords and operator symbols
  • Line spacing
  • Placement of method parameters within method declarations or method calls
  • Standard ordering of elements within a class
  • Formatting of documentation within element headers and file headers
  • Naming of elements, fields and variables
  • Use of the built-in types
  • Use of access modifiers
  • Allowed contents of files
  • Debugging text


詳細は、上記のサイトを参照