挽星

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

使用StyleCop对项目的编码质量情况进行检查,却对编码规范有了一个详细的了解,

在检查的过程中遇到了许多编码方式上的错误,很有价值,总结一下:

1、SA1609: The public or protected property's documentation header must contain a value tag.

2、SA1629: The documentation text within the param tag must end with a period.

3、SA1516: Adjacent elements must be separated by a blank line.

4、SA1503: The body of the if statement must be wrapped in opening and closing curly brackets.

5、SA1513: Statements or elements wrapped in curly brackets must be followed by a blank line.

6、SA1515: A single-line comment must be preceded by a blank line or another single-line comment, or must be the first item in its scope. To ignore this error when commenting out a line of code, begin the comment with '////' rather than '//'.

7、SA1513: Statements or elements wrapped in curly brackets must be followed by a blank line.

8、SA1505: An opening curly bracket must not be followed by a blank line.

9、SA1101: The call to own member of a object must begin with the 'this.' prefix to indicate that the item is a member of the class.

10、SA1122: Use string.Empty rather than "".

11、SA1630: The documentation text within the value tag does not contain any whitespace between words, indicating that it most likely does not follow a proper grammatical structure required for documentation text.

12、SA1600: The field must have a documentation header.

13、SA1119: The line contains unnecessary parenthesis.

14、KU0001: The line is too long. It may not exceed 160 characters.

15、SA1119: The line contains unnecessary parenthesis(括号).

16、SA1201: All properties must be placed after all constructors.

17、SA1210: Using directives must be sorted alphabetically by the namespaces.

18、SA1003: The spacing around the symbol '=' is invalid.

19、SA1108: A comment may not be placed within the bracketed statement.

20、SA1001: Invalid spacing around the comma.

21、SA1100: The call to Subject should only use the 'base.' prefix if the item is declared virtual in the base class and an override is defined

in the local class. Otherwise, prefix the call with this rather than base.

22、SA1117: All method parameters must be placed on the same line, or each parameter must be placed on a separate line.








对于错误的修改,还可以使用一些工具:

http://stylecopforresharper.codeplex.com/

http://stylefix.codeplex.com/

StyleFix tool can fix below violation automatically








posted on 2011-01-28 18:02  挽星  阅读(1357)  评论(0)    收藏  举报