Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@msridhar
Copy link
Collaborator

@msridhar msridhar commented Nov 3, 2025

This seems to have a global side effect that causes weird test failures in #1323, and it's a bit of a hack. Instead, move the relevant tests to the test-library-model module where no such hacks are required. Test-only changes.

Summary by CodeRabbit

  • New Features

    • Added capability to suggest removal of unnecessary non-null casts from library models
  • Tests

    • Expanded test coverage for library model scenarios with new test cases
  • Chores

    • Updated build dependencies and test configuration

@msridhar
Copy link
Collaborator Author

msridhar commented Nov 3, 2025

Confirmed that the changes in this PR make the tests pass in #1323

@msridhar msridhar enabled auto-merge (squash) November 3, 2025 19:42
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

This pull request refactors the test infrastructure for library models across multiple modules. The code-coverage-report module adds a dependency on test-library-models. The nullaway module removes a test method and related imports from AutoSuggestTest. The test-library-models module gains a new Gradle plugin configuration and test dependencies, adds a new method mapping to TestLibraryModels for cast operations, and restructures CustomLibraryModelsTests to use BugCheckerRefactoringTestHelper instead of extending NullAwayTestsBase, while adding a new test method for verifying unnecessary cast removal.

Suggested reviewers

  • yuxincs

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: removing the practice of passing -processorpath to CompilationTestHelper in NullAway tests, which is the central objective of the PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch stop-passing-processorpath

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 334479c and 43d50dd.

📒 Files selected for processing (5)
  • code-coverage-report/build.gradle (1 hunks)
  • nullaway/src/test/java/com/uber/nullaway/AutoSuggestTest.java (0 hunks)
  • test-library-models/build.gradle (2 hunks)
  • test-library-models/src/main/java/com/uber/nullaway/testlibrarymodels/TestLibraryModels.java (1 hunks)
  • test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java (2 hunks)
💤 Files with no reviewable changes (1)
  • nullaway/src/test/java/com/uber/nullaway/AutoSuggestTest.java
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: msridhar
Repo: uber/NullAway PR: 1245
File: guava-recent-unit-tests/src/test/java/com/uber/nullaway/guava/NullAwayGuavaParametricNullnessTests.java:101-102
Timestamp: 2025-08-14T18:50:06.159Z
Learning: In NullAway JSpecify tests, when JDK version requirements exist due to bytecode annotation reading capabilities, prefer failing tests over skipping them on unsupported versions to ensure CI catches regressions and enforces proper JDK version usage for developers.
Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.
📚 Learning: 2025-08-14T18:50:06.159Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1245
File: guava-recent-unit-tests/src/test/java/com/uber/nullaway/guava/NullAwayGuavaParametricNullnessTests.java:101-102
Timestamp: 2025-08-14T18:50:06.159Z
Learning: In NullAway JSpecify tests, when JDK version requirements exist due to bytecode annotation reading capabilities, prefer failing tests over skipping them on unsupported versions to ensure CI catches regressions and enforces proper JDK version usage for developers.

Applied to files:

  • test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java
  • test-library-models/build.gradle
📚 Learning: 2025-08-28T04:54:20.953Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.

Applied to files:

  • test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java
  • test-library-models/src/main/java/com/uber/nullaway/testlibrarymodels/TestLibraryModels.java
🧬 Code graph analysis (1)
test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java (1)
nullaway/src/main/java/com/uber/nullaway/generics/JSpecifyJavacConfig.java (1)
  • JSpecifyJavacConfig (16-59)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build and test on ubuntu-latest
  • GitHub Check: Build and test on windows-latest
  • GitHub Check: Build and test on macos-latest
  • GitHub Check: Build spring-framework with snapshot
  • GitHub Check: Build caffeine with snapshot
🔇 Additional comments (7)
test-library-models/build.gradle (2)

21-21: LGTM! Test conventions plugin added appropriately.

Adding the nullaway.java-test-conventions plugin enables proper test infrastructure for this module.


31-36: LGTM! Test dependencies properly configured.

The test dependencies are correctly added with appropriate exclusions. The JUnit exclusion from errorProneTestHelpers prevents version conflicts, and dependencies on :nullaway and :test-java-lib provide the necessary testing infrastructure.

code-coverage-report/build.gradle (1)

88-88: LGTM! Includes test-library-models in coverage reporting.

Adding the test-library-models dependency ensures its tests and code are included in the overall coverage calculations, which is appropriate given the module now contains executable tests.

test-library-models/src/main/java/com/uber/nullaway/testlibrarymodels/TestLibraryModels.java (1)

92-92: LGTM! Library model mapping correctly configured.

The new mapping for com.uber.Test.castToNonNull(String, T, int) correctly identifies parameter index 1 (the T value parameter) as the one being cast to non-null. This supports the new test in CustomLibraryModelsTests.

test-library-models/src/test/java/com/uber/nullaway/CustomLibraryModelsTests.java (3)

34-38: LGTM! Successfully removes the processorpath hack.

The refactored helper method no longer manipulates the processor path, which was the goal of this PR. The TestLibraryModels class will now be loaded via the @AutoService mechanism instead of explicit -processorpath configuration, eliminating the global side effects mentioned in issue #1323.


40-40: LGTM! TemporaryFolder Rule added for test isolation.

The TemporaryFolder Rule provides proper test isolation by ensuring each test gets a clean output directory for compilation artifacts.


287-328: LGTM! Well-structured test for library model cast suggestions.

This test correctly validates that NullAway can suggest removing unnecessary casts when:

  1. A method is defined as a cast-to-non-null method in the library model (via the new mapping in TestLibraryModels.java)
  2. The parameter being cast is already non-null (Object o without @Nullable)

The test appropriately uses BugCheckerRefactoringTestHelper to verify the suggested refactoring from Test.castToNonNull("CAST_REASON", o, 42) to simply o.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@msridhar msridhar disabled auto-merge November 3, 2025 19:44
@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.44%. Comparing base (334479c) to head (43d50dd).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1326      +/-   ##
============================================
+ Coverage     88.37%   88.44%   +0.06%     
- Complexity     2549     2563      +14     
============================================
  Files            95       96       +1     
  Lines          8543     8594      +51     
  Branches       1705     1705              
============================================
+ Hits           7550     7601      +51     
  Misses          499      499              
  Partials        494      494              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msridhar msridhar enabled auto-merge (squash) November 3, 2025 19:45
@msridhar msridhar merged commit 38a7561 into master Nov 4, 2025
11 checks passed
@msridhar msridhar deleted the stop-passing-processorpath branch November 4, 2025 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants