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

Skip to content

Conversation

@msridhar
Copy link
Collaborator

@msridhar msridhar commented Nov 19, 2025

Make sure @Contract("null -> null") is not being interpreted incorrectly. Test-only change.

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for contract null-safety validation scenarios.

@msridhar msridhar requested a review from yuxincs November 19, 2025 17:38
@msridhar msridhar enabled auto-merge (squash) November 19, 2025 17:38
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 19, 2025

Walkthrough

A new static method uselessContract(@nullable Object o) was added to the NullnessChecker test class, accompanied by a corresponding test case. This method is annotated with a contract and returns a nullable object. The test case exercises the contract behavior and verifies that diagnostics are still produced when using this contract configuration.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 'Add a test for a useless @contract' is clear and directly summarizes the main change: adding a new test case for contract annotation behavior in NullAway.
✨ 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 contract-test

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39d65f8 and 4fc1af9.

📒 Files selected for processing (1)
  • nullaway/src/test/java/com/uber/nullaway/ContractsTests.java (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 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:

  • nullaway/src/test/java/com/uber/nullaway/ContractsTests.java
🔇 Additional comments (2)
nullaway/src/test/java/com/uber/nullaway/ContractsTests.java (2)

176-178: uselessContract contract and signature correctly model a “no-op” contract for NullAway.

The @Contract("null -> null") on uselessContract matches the implementation (return o;) and keeps the method return type @Nullable, so it doesn’t accidentally imply non-null on non-null inputs. This cleanly encodes the “useless” contract scenario the PR is targeting.


195-199: New test4 precisely asserts that @Contract("null -> null") doesn’t suppress the nullable-return diagnostic.

Using a non-null Object o4 argument while expecting // BUG: Diagnostic contains: returning @Nullable expression is the right way to guard against misinterpreting the contract as strengthening the return type; this directly tests the PR objective.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.41%. Comparing base (39d65f8) to head (4fc1af9).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1346   +/-   ##
=========================================
  Coverage     88.41%   88.41%           
  Complexity     2582     2582           
=========================================
  Files            97       97           
  Lines          8664     8664           
  Branches       1722     1722           
=========================================
  Hits           7660     7660           
  Misses          504      504           
  Partials        500      500           

☔ 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 merged commit fdec09a into master Nov 19, 2025
11 checks passed
@msridhar msridhar deleted the contract-test branch November 19, 2025 17:50
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