Skip to content

Conversation

@aschackmull
Copy link
Contributor

The two libraries do very similar things and overlap somewhat with neither being a subset of the other. This PR consolidates the models of both libraries into a single library and ensures that it is properly recognized by the Guards library.

@github-actions github-actions bot added the Java label Sep 5, 2025
@aschackmull aschackmull force-pushed the java/preconditions branch 3 times, most recently from 63fae98 to 39578c6 Compare September 8, 2025 07:00
@aschackmull aschackmull marked this pull request as ready for review September 8, 2025 07:29
@aschackmull aschackmull requested a review from a team as a code owner September 8, 2025 07:29
Copilot AI review requested due to automatic review settings September 8, 2025 07:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR consolidates two similar libraries (Assertions.qll and Preconditions.qll) that provide overlapping functionality for modeling assertion and precondition checks. The consolidation centralizes this functionality into the enhanced Preconditions.qll library and updates all references accordingly.

  • Deprecates the existing Assertions.qll library
  • Expands Preconditions.qll with comprehensive assertion and precondition modeling
  • Updates all import statements and method calls to use the consolidated library

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
DeadLocals.qll Updates import from Assertions to Preconditions and inlines assertion logic
Assertions.qll Marks library as deprecated
Nullness.qll Switches import from Assertions to Preconditions and simplifies null checking logic
Preconditions.qll Consolidates functionality from both libraries with new predicates and deprecation notices
Guards.qll Updates method calls to use new consolidated API
ControlFlowGraph.qll Updates method calls to use new consolidated API

@aschackmull aschackmull force-pushed the java/preconditions branch 3 times, most recently from 7b62eb8 to 2145a88 Compare September 10, 2025 11:13
@aschackmull
Copy link
Contributor Author

Finally got a dca run that I'm happy with. There are a number of small result changes, so I've added a change note to cover that.

|
ma.getAnArgument().(MethodCall).getMethod().getName() = "notNullValue"
)
private ControlFlowNode ensureNotNull(SsaVariable v) { result = varDereference(v, _) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the QlDoc needs to be changed as the assertion related logic has been removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, that needs a slight cleanup. Do you mind if I postpone that to #20367? (Which I'm going to rebase once this is merged)

*/
overlay[local?]
module;
deprecated module;
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice that it is possible to deprecate the entire module!

Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

LGTM!

@aschackmull aschackmull merged commit e8ddac0 into github:main Sep 12, 2025
17 checks passed
@aschackmull aschackmull deleted the java/preconditions branch September 12, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants