1. 程式人生 > >SonarQube規則之壞味道類型

SonarQube規則之壞味道類型

for in jna dcl cut sam ted 可能 per 制表符

1、Abbreviation As Word In Name (默認 關閉)
壞味道 主要
檢查驗證標識符名稱中的縮寫(連續大寫字母)長度,還允許執行駱駝案例命名
allowedAbbreviationLength 3
6、Annotation Location (默認 關閉)
壞味道 主要
註釋位置
allowSamelineSingleParameterlessAnnotation
To allow single parameterless annotation to be located on the same line as target element.
默認值true
allowSamelineParameterizedAnnotation


To allow parameterized annotation to be located on the same line as target element.
默認值false
allowSamelineMultipleAnnotations
To allow annotation to be located on the same line as target element.
默認值false
tokens
tokens to check
默認值CLASS_DEF,INTERFACE_DEF,ENUM_DEF,METHOD_DEF,CTOR_DEF,VARIABLE_DEF
7、Annotation Use Style (默認 關閉)

壞味道 主要
trailingArrayComma
Defines the policy for trailing comma in arrays. Default is never.
closingParens

Defines the policy for ending parenthesis. Default is never.
elementStyle

Defines the annotation element styles. Default value is compact_no_array.
8、Artifact ids should follow a naming convention (默認 關閉)

壞味道 次要
共享命名約定允許團隊有效協作。 當pom的artifactId與提供的正則表達式不匹配時,此規則引發了一個問題
regex The regular expression the "artifactId" should match
默認值[a-z][a-z-0-9]+
9、At-clause Order (默認 關閉)
壞味道 主要
檢查從句順序
tagOrder
allows to specify the order by tags.
默認值
@author,@version,@param,@return,@throws,@exception,@see,@since,@serial,@serialField,@serialData,@deprecated target allows to specify targets to check at-clauses.
10、Avoid Escaped Unicode Characters (默認 關閉)
壞味道 主要
避免轉義的Unicode字符
allowIfAllCharactersEscaped
Allow if all characters in literal are escaped.
默認值false
allowNonPrintableEscapes
Allow non-printable escapes.
默認值false
allowByTailComment
Allow use escapes if trail comment is present.
默認值false
allowEscapesForControlCharacters
Allow use escapes for non-printable(control) characters.
默認值false
11、Avoid Nested Blocks (默認 關閉)
壞味道 主要
避免嵌套塊
allowInSwitchCase
Allow nested blocks in case statements. Default is false.
12、Avoid Star Import (默認 關閉)
壞味道 次要
檢查發現使用*符號的導入語句
excludes packages where star imports are allowed. Note that this property is not recursive, subpackages of excluded packages are not automatically excluded.
allowStaticMemberImports
whether to allow starred static member imports like <code>import static org.junit.Assert.*;</code>. Default is false.
默認值false
allowClassImports whether to allow starred class imports like <code>import java.util.*;</code>. Default is false.
默認值false
13、Boolean Expression Complexity (默認 關閉)
壞味道 主要
將嵌套布爾運算符(&&,||和^)限制為指定的深度(默認= 3)。
max the maximum allowed number of boolean operations in one expression. Default is 3.
默認值3
tokens tokens to check. Default is LAND,BAND,LOR,BOR,BXOR.
默認值LAND,BAND,LOR,BOR,BXOR
14、Branches should have sufficient coverage by tests (默認 關閉)
壞味道 主要
分支應有足夠的測試覆蓋
minimumBranchCoverageRatio
默認值65
15、Catch Parameter Name (默認 關閉)
壞味道 主要
檢查catch參數名是否符合format屬性指定的格式
format Specifies valid identifiers. Default is ^(e|t|ex|[a-z][a-z][a-zA-Z]+)$
默認值^(e|t|ex|[a-z][a-z][a-zA-Z]+)$
16、Class Data Abstraction Coupling (默認 關閉)
壞味道 主要
度量衡量給定類中其他類的實例化數。
max the maximum threshold allowed. Default is 7.
excludedClasses User-configured class names to ignore.
excludeClassesRegexps User-configured regular expressions to ignore classes
excludedPackages User-configured packages to ignore
17、Class Fan Out Complexity (默認 關閉)
壞味道 主要
類的依賴類數量
max the maximum threshold allowed. Default is 20.
excludedClasses
User-configured class names to ignore
excludeClassesRegexps
User-configured regular expressions to ignore classes
excludedPackages
User-configured packages to ignore
18、Class names should comply with a naming convention (開放)
壞味道 次要
類名應符合命名約定
format Regular expression used to check the class names against.
默認值^[A-Z][a-zA-Z0-9]*$
19、Classes from "sun.*" packages should not be used (開放)
壞味道 主要
不得使用“sun.*”軟件包的類,sun類*或com.sun *包被視為實現細節,不屬於Java API
Exclude Comma separated list of Sun packages to be ignored by this rule. Example: com.sun.jna,sun.misc
20、Classes should not be coupled to too many other classes (Single Responsibility Principle) (默認 關閉)
壞味道 主要
類不應與太多其他類(單一責任原則)相耦合(依賴)
max Maximum number of classes a single class is allowed to depend upon
默認值20
21、Classes should not be too complex (默認 關閉)
壞味道 嚴重 廢棄
類不應太復雜
max Maximum complexity allowed.
默認值200
22、Classes should not have too many "static" imports (默認 關閉)
壞味道 主要
靜態導入類允許您使用其公共靜態成員,而不必使用類名。 這可以很方便,但如果靜態導入太多的類,你的代碼可能會變得混亂,很難維護
threshold The maximum number of static imports allowed
默認值4
23、Classes should not have too many fields (默認 關閉)
壞味道 主要
類不應有太多字段
countNonpublicFields
Whether or not to include non-public fields in the count
默認值true
maximumFieldThreshold
The maximum number of fields
默認值20
24、Classes should not have too many methods (默認 關閉)
壞味道 主要
類不應該有太多方法
countNonpublicMethods
Whether or not to include non-public methods in the count.
默認值true
maximumMethodThreshold
The maximum number of methods authorized in a class.
默認值35
25、Close curly brace and the next "else", "catch" and "finally" keywords should be located on the same line (默認 關閉)
壞味道 次要
關閉大括號,下一個“else”,“catch”和“finally”關鍵字應位於同一行
26、Close curly brace and the next "else", "catch" and "finally" keywords should be on two different lines (默認 關閉)
壞味道 次要
關閉大括號和下一個“else”,“catch”和“finally”關鍵字應該在兩個不同的行
29、Comments should not be located at the end of lines of code (默認 關閉)
壞味道 次要
註釋不應位於代碼行的末尾
legalTrailingCommentPattern
Description Pattern for text of trailing comments that are allowed. By default, comments containing only one word.
默認值^\s*+[^\s]++$
30、Constant Name (默認 關閉)
壞味道 次要
檢查常數名稱是否符合指定的格式
applyToPackage
Controls whether to apply the check to package-private member
默認值true
format Regular expression
默認值^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$
applyToPublic
Controls whether to apply the check to public member
默認值true
applyToProtected
Controls whether to apply the check to protected member
默認值true
applyToPrivate Controls whether to apply the check to private member
默認值true
31、Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply (默認 關閉)
壞味道 嚴重
控制流程語句“if”,“for”,“while”,“switch”和“try”不能嵌套太深
max Maximum allowed control flow statement nesting depth.
默認值3
32、Custom Import Order (默認 關閉)
壞味道 主要
檢查導入聲明組按照用戶指定的順序顯示。 如果有導入,但是在組態中未指定其組,則導入應放在導入列表的末尾。
thirdPartyPackageRegExp RegExp for THIRDPARTY_PACKAGE group imports.
默認值^$
separateLineBetweenGroups
Force empty line separator between import groups.
默認值true
sortImportsInGroupAlphabetically
Force grouping alphabetically.
默認值false
specialImportsRegExp
RegExp for SPECIAL_IMPORTS group imports.
默認值^$
customImportOrderRules List of order declaration customizing by user. standardPackageRegExp
RegExp for STANDARD_JAVA_PACKAGE group imports.
默認值java|javax
33、Cyclomatic Complexity (默認 關閉)
壞味道 主要
檢查針對特定限制的方法的循環復雜性
switchBlockAsSingleDecisionPoint whether to treat the whole switch block as a single decision point
默認值false
max the maximum threshold allowed.
默認值10
tokens
tokens to check
默認值
LITERAL_WHILE,LITERAL_DO,LITERAL_FOR,LITERAL_IF,LITERAL_SWITCH,LITERAL_CASE,LITERAL_CATCH,QUESTION,LAND,LOR
34、Default Comes Last (默認 關閉)
壞味道 主要
檢查在switch語句中的所有情況之後的默認值。
skipIfLastAndSharedWithCase
whether to allow default along with case if they are not last
默認值false
35、Empty catch block (默認 關閉)
壞味道 主要
檢查空的catch塊。 有兩個選項可以使驗證更加精確(默認情況下,檢查允許空的catch塊和任何註釋)
exceptionVariableName Format of skipping exception‘‘s variable name.
默認值^$
commentFormat
Format of comment.
默認值.*
36、Empty For Initializer Pad (默認 關閉)
壞味道 次要
檢查初始化程序為空的填充; 那是空的是否需要一個空的初始化程序,或者禁止這樣的空格。 示例:for(; i <j; i ++,j--)
option policy on how to pad an empty for iterator
37、Empty For Iterator Pad
壞味道 次要
檢查一個空的填充叠代器; 那就是空格是否需要一個空的叠代器,否則這樣的空格是被禁止的。 示例:for(Iterator foo = very.long.line.iterator(); foo.hasNext();)
option policy on how to pad an empty for iterator
38、Empty Line Separator (默認 關閉)
壞味道 主要
在標題,包,所有導入聲明,字段,構造函數,方法,嵌套類,靜態初始化器和實例初始化器之後檢查空行分隔符
allowNoEmptyLineBetweenFields
Allow no empty line between fields
默認值false
allowMultipleEmptyLines
Allows multiple empty lines between class members.
默認值true
tokens
assignments to check
默認值
PACKAGE_DEF,IMPORT,CLASS_DEF,INTERFACE_DEF,ENUM_DEF,STATIC_INIT,INSTANCE_INIT,METHOD_DEF,CTOR_DEF,VARIABLE_DEF
allowMultipleEmptyLinesInsideClassMembers
Allow multiple empty lines inside class members
默認值true
39、Executable Statement Count (默認 關閉)
壞味道 主要
將可執行語句的數量限制為指定的限制(默認= 30)。
max the maximum threshold allowed. Default is 30.
默認值30
tokens members to check
默認值
CTOR_DEF,METHOD_DEF,INSTANCE_INIT,STATIC_INIT
40、Expressions should not be too complex (默認 關閉)
壞味道 嚴重
表達式不應太復雜
max Maximum number of allowed conditional operators in an expression
默認值3
42、File Length (默認 關閉)
壞味道 主要
如果源文件變得很長,那麽很難理解。 因此,長類通常應該重構到專註於特定任務的幾個單獨的類中
fileExtensions
file type extension of files to process
max maximum allowable number of lines. Default is 2000.
43、File Tab Character (默認 關閉)
壞味道 次要
檢查源代碼中沒有制表符(‘\ t‘)
fileExtensions
file type extension of files to process
eachLine whether to report on each line containing a tab, or just the first instance. Default is false.
44、Files should contain an empty new line at the end (默認 關閉)
壞味道 次要
文件最後應該包含一個空的新行

SonarQube規則之壞味道類型