-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from AstuteSource/issue-#6
XPath expressions that broaden the number of anti-patterns checked.
- Loading branch information
Showing
7 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
checks: | ||
- name: "Void Function" | ||
code: "VF" | ||
id: "C001" | ||
pattern: 'count(//Function//For|If|Return|Assign)' | ||
count: | ||
min: null | ||
max: null | ||
- name: "Nested Depth (Set value)" | ||
code: "ND" | ||
id: "F001" | ||
pattern: '//FunctionDef//FunctionDef/ancestor::*' | ||
count: | ||
min: null | ||
max: null | ||
- name: "Number of conditions (if, if-else, and switch) in a Function" | ||
code: "#Cond" | ||
id: "F002" | ||
pattern: '//FunctionDef//If/following-sibling::If | //FunctionDef//If/following-sibling::Elif | //FunctionDef//If/following-sibling::Else' | ||
count: | ||
min: null | ||
max: null | ||
- name: "The number of nested conditions (e.g., if{if{}}) in a Function" | ||
code: "IFIF" | ||
id: "CL001" | ||
pattern: '//FunctionDef//If/descendant::If' | ||
count: | ||
min: null | ||
max: null | ||
- name: "The number of nested condition-loops (e.g., if{for{}}) in a Function" | ||
code: "IFOR" | ||
id: "CL002" | ||
pattern: '//FunctionDef//For//if' | ||
count: | ||
min: null | ||
max: null | ||
- name: "The number of nested loop-conditions (e.g., for{if{}}) in a Function" | ||
code: "VFF" | ||
id: "C002" | ||
pattern: '//FunctionDef[//(If/following-sibling::For | For/following-sibling::If)]' | ||
count: | ||
min: null | ||
max: null | ||
- name: "The number of nested loop-conditions (e.g., for{for{}}) in a Function" | ||
code: "FF" | ||
id: "F001" | ||
pattern: '//FunctionDef//For[.//For]' | ||
count: | ||
min: null | ||
max: null | ||
- name : "number-of-assertions" | ||
code: "NOA" | ||
id: "NOA001" | ||
pattern : "//FunctionDef[@type='str']/body/Assert" | ||
count: | ||
min: null | ||
max: null | ||
- name : "count-test-method-lines" | ||
code: "LOF" | ||
id: "LOF001" | ||
pattern : "//FunctionDef[@type='str' and starts-with(@name, 'test_')]/body/*" | ||
count: | ||
min: null | ||
max: null | ||
- name: "count-method-lines" | ||
pattern: "//FunctionDef[@type='str']/body/* | //FunctionDef[@type='str']/body/Return" | ||
code: "CML" | ||
id: "CML001" | ||
count: | ||
min: null | ||
max: null | ||
- name : "test-methods-invoking-method" | ||
code: "TMIM" | ||
id: "TMIM001" | ||
pattern : "//Assert[count(.//Call[func/Name/@id='test_function']) > 0]" | ||
count: | ||
min: null | ||
max: null | ||
- name: "is-void" | ||
code: "IVI" | ||
id: "V001" | ||
pattern: "//method[@returnType='void']" | ||
count: | ||
min: null | ||
max: null | ||
- name: "non-void-percent" | ||
code: "NVP" | ||
id: "V002" | ||
pattern: "count(/class/method[@returnType != 'void'])" | ||
count: | ||
min: null | ||
max: null | ||
- name: "getter-percent" | ||
code: "GPT" | ||
id: "GP001" | ||
pattern: "concat(count(//method[starts-with(@name, 'get') or starts-with(@name, 'is')]), '/', count(//method[starts-with(@name, 'get') or starts-with(@name, 'is')]))" | ||
count: | ||
min: null | ||
max: null | ||
- name: "is-public" | ||
code: "IPP" | ||
id: "IP001" | ||
pattern: "//method[@access='public']" | ||
count: | ||
min: null | ||
max: null | ||
- name: "is-static" | ||
code: "IST" | ||
id: "IS001" | ||
pattern: "//method[(@static) or @static='true']" | ||
count: | ||
min: null | ||
max: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ chasten: | |
# point to a checks file | ||
checks-file: | ||
- checks.yml | ||
- Zhu_.yml |
Submodule chasten-test
added at
2d8478
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters