使用StyleCop進行代碼審查
StyleCop analyzes C# source code to enforcea set of style and consistency rules. It can be run from inside of Visual Studio orintegrated into an MSBuild project
SourceAnalysis(StyleCop)不是代碼格式化(代碼美化)工具,而是代碼規範檢查工具(CodeReview 工具),它不僅僅檢查代碼格式,而是編碼規範,包括命名和注釋等。SourceAnalysis(StyleCop)目的是幫助項目團隊執行一係列常用的源代碼格式規範,這些規範是關於如何開發布局規整,易讀,易維護並且文檔良好的優雅代碼的(help teams enforce a common set of best practices for layout, readability,maintainability, and documentation of C# source code)。
SourceAnalysis (StyleCop) 現在包含了 200 個左右的最佳實踐規則(bestpractice rules),這些規則與 VisualStudio 2005 和 VisualStudio 2008 中默認的代碼格式化規則是一致的。
SourceAnalysis(StyleCop)可以作為 Visual studio 的插件運行.
同時SourceAnalysis (StyleCop)也可以作為 MSBuild 任務(安裝時有選項)通過命令行執行。
SourceAnalysis(StyleCop)是代碼級別的,更適合於程序員在編程過程中使用。
SourceAnalysis(StyleCop)不提供靈活的規則設置,而是使用所謂 one-size-fits-all的方式強製人們用同樣的習慣書寫代碼,因此 SourceAnalysis (StyleCop)的終極目標是:The ultimate goal of Source Analysis is to allow you to produce elegant,consistent code that your team members and others who view your code will findhighly readable.
SourceAnalysis(StyleCop)檢查的規則包括:
布局(Layout of elements, statements,expressions, and query clauses )
括號位置(Placement of curly brackets,parenthesis, square brackets, etc )
空格(Spacing around keywords andoperator symbols )
行距(Line spacing )
參數位置(Placement of method parameterswithin method declarations or method calls )
元素標準排列(Standard ordering of elementswithin a class )
注釋格式(Formatting of documentationwithin element headers and file headers )
命名(Naming of elements, fields andvariables )
內置類型的使用(Use of the built-in types )
訪問修飾符的使用(Use of access modifiers )
文件內容(Allowed contents of files )
Debugging文本(Debugging text)
開始使用這些工具時可能會覺得對我們要求太苛刻,但根據微軟自己的經驗:aftera short adjustment period, they came to appreciate the rules enforced by SourceAnalysis, and even began to find it difficult to read code not written in thisstyle.
原文地址:原文地址
工具下載地址:工具下載地址
使用圖例如下:
最後更新:2017-04-03 12:54:31
上一篇:
mac os X下的updatedb
下一篇:
拚圖遊戲的數學原理
月球趣事——月全食的作用
C++編程規範之14:寧要編譯和連接時錯誤,也不要運行時錯誤
文本文件和二進製文件
嘉興:打造新型智慧城市新標杆
DriverStudio 和 WDF驅動 通過GUID獲取設備句柄的差別
jqm視頻播放器,html5視頻播放器,html5音樂播放器,html5播放器,video開發demo,html5視頻播放示例,html5手機視頻播放器
論創業者心態心智
VS2010 Tips: How to change Local Help Library path
分布式消息中間件Metaq發布1.4.3
DataGrid和DataGridComboBoxColumn數據綁定