-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Rust: Add metric for DCA and debug predicates for type that reach the length limit #20147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @name Nodes With Type At Length Limit | ||
* @description Counts the number of AST nodes with a type at the type path length limit. | ||
* @kind metric | ||
* @id rust/summary/nodes-at-type-path-length-limit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want me to talk you through adding this metric to the DCA reports (and our metrics issue) - or would you prefer I do it for you? I'm happy either way assuming this is the only metric you have plans to add right now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I can add the metric to DCA but it would be great to have your eyes on the PR! Regarding the metrics issue it's up to you if we add it there or not. It obviously be nice to have, but may not be important enough to include. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm happy to track it in metrics, it won't be among the fiddlier bits to track. |
||
* @tags summary | ||
*/ | ||
|
||
import rust | ||
import codeql.rust.internal.TypeInference | ||
|
||
from int atLimit | ||
where | ||
atLimit = | ||
count(AstNode n, TypePath path | | ||
exists(inferType(n, path)) and path.length() = getTypePathLimit() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come this is I'm a bit suspicious because in at least one case I get more results when I increase the threshold. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The length can never be greater than In the debug predicate changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, and when the path limit is increased we potentially get more results because of more (longer) spurious / multiple paths being permitted and counted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes :) |
||
| | ||
n | ||
) | ||
select atLimit |
Uh oh!
There was an error while loading. Please reload this page.