使用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数据绑定