Skip to content
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

Java: Add diagnostic query for framework coverage #7181

Merged
merged 3 commits into from Nov 24, 2021

Conversation

@bmuskalla
Copy link
Contributor

@bmuskalla bmuskalla commented Nov 19, 2021

No description provided.

@bmuskalla bmuskalla requested a review from as a code owner Nov 19, 2021
@github-actions github-actions bot added the Java label Nov 19, 2021
@bmuskalla bmuskalla changed the title Simplify diagnostic query Java: Simplify diagnostic query Nov 19, 2021
@bmuskalla bmuskalla changed the title Java: Simplify diagnostic query Java: Add diagnostic query for framework coverage Nov 19, 2021
modelCoverage(package, _, _, type, _) and
packageAndType = package + ";" + type and
rows = sum(int n | modelCoverage(package, _, _, type, n) | n)
Copy link
Contributor

@aschackmull aschackmull Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sum is wrong. You're adding all the different ints that satisfy modelCoverage(package, _, _, type, n), so if two kinds happen to have the exact same number of models, then those numbers won't be added. You'll need to add string kind in the range. Another minor thing: If you change sum to strictsum, then it'll bind package and type so you can drop the first line.

Suggested change
modelCoverage(package, _, _, type, _) and
packageAndType = package + ";" + type and
rows = sum(int n | modelCoverage(package, _, _, type, n) | n)
packageAndType = package + ";" + type and
rows = strictsum(int n, string kind | modelCoverage(package, _, kind, type, n) | n)

Loading

Copy link
Contributor Author

@bmuskalla bmuskalla Nov 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. The kind thing is tricky, that's hard to see.

Regarding strictsum - do you think it might be worth mentioning that on https://codeql.github.com/docs/ql-language-reference/expressions/ ?
Currently it just says strictconcat, strictcount, and strictsum: These aggregates work like concat, count, and sum respectively, except that they are strict. That is, if there are no possible assignments to the aggregation variables that satisfy the formula, then the entire aggregation fails and evaluates to the empty set (instead of defaulting to 0 or the empty string). This is useful if you’re only interested in results where the aggregation body is non-trivial..

Loading

Copy link
Contributor

@aschackmull aschackmull Nov 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the missing kind in the range has nothing to do with the switch from sum to strictsum. The explanation of strictsum that you linked seems perfectly adequate.

Loading

@bmuskalla bmuskalla requested a review from aschackmull Nov 23, 2021
@aschackmull aschackmull merged commit a3b263e into github:main Nov 24, 2021
8 checks passed
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants