You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are certain situations in which chasten over-count the presence of
specific source code patterns. For instance, when the tool uses the following
XPath expression to count the number of test cases:
checks:
- name: "all-non-test-function-definition"code: "FUNC"id: "FUNC001"description: "First executable line of a non-test function, skipping over docstrings and/or comments"pattern: '//FunctionDef[not(contains(@name, "test_"))]/body/Expr[value/Constant]/following-sibling::*[1] | //FunctionDef[not(contains(@name, "test_"))]/body[not(Expr/value/Constant)]/*[1]'
- name: "all-test-function-definition"code: "FUNC"id: "FUNC002"description: "First executable line of a test function, skipping over docstrings and/or comments"pattern: '//FunctionDef[starts-with(@name, "test_")]/body/Expr[value/Constant]/following-sibling::*[1] | //AsyncFunctionDef[starts-with(@name, "test_")]/body/Expr[value/Constant]/following-sibling::*[1] | //FunctionDef[starts-with(@name, "test_")]/body[not(Expr/value/Constant)]/*[1] | //AsyncFunctionDef[starts-with(@name, "test_")]/body[not(Expr/value/Constant)]/*[1]'count:
min: 1max: 10
And a program has source code that looks like this:
it will return a count of 2 test cases even though, from the perspective of pytest there is only one executable test case! Are there any intelligent ways
in which we can improve the XPath expressions or detect when the tool is likely
to over-count or under-count the presence of specific types of AST nodes?
The text was updated successfully, but these errors were encountered:
I never got far with taking a stab at this. We will leave this issue on hold for now. Here is the single thing I figured out as I was researching this:
I think that this has more to do with how the XPath expressions are written, which gives more motivation to why we would want to warn the user in the case of an expression that could potentially over or under count. For anyone to take on this issue, they must spend time understanding how the wildcard * works.
There are certain situations in which
chasten
over-count the presence ofspecific source code patterns. For instance, when the tool uses the following
XPath expression to count the number of test cases:
And a program has source code that looks like this:
it will return a count of
2
test cases even though, from the perspective ofpytest
there is only one executable test case! Are there any intelligent waysin which we can improve the XPath expressions or detect when the tool is likely
to over-count or under-count the presence of specific types of AST nodes?
The text was updated successfully, but these errors were encountered: