Skip to content

Refactor CoreTests and UnannotatedTests to use addSourceLines and inline test data - #1426

Merged
msridhar merged 3 commits into
uber:masterfrom
cobayo:issue-1425
Jan 6, 2026
Merged

msridhar merged 3 commits into
uber:masterfrom
cobayo:issue-1425

Conversation

@cobayo

@cobayo cobayo commented Jan 2, 2026 •

Copy link
Copy Markdown
Contributor

Refactor UnannotatedTests to inline multiple test data files

Description

Following the suggestion in #1425, this PR modernizes the test cases in UnannotatedTests.java by inlining external source files. This improves test maintainability and removes reliance on deprecated addSourceFile calls.

Changes

  • Migrated all test cases in UnannotatedTests.java from addSourceFile to addSourceLines.
  • Deleted the original source files from the testdata directory.
  • Removed unnecessary @SuppressWarnings("deprecation") annotations.

Checklist

  • A description about what and why you are contributing, even if it's trivial.
  • The issue number(s) or PR number(s) in the description if you are contributing in response to those.
  • If applicable, unit tests. (Verified with existing tests)

Summary by CodeRabbit

  • Tests
    • Consolidated multiple external test resource files into inline source definitions to simplify test setup.
    • Removed several standalone test resource files now provided inline.
    • Removed a deprecation suppression annotation from a public test class declaration.

✏️ Tip: You can customize this high-level summary in your review settings.

@CLAassistant

CLAassistant commented Jan 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jan 2, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Replaces deprecated CompilationTestHelper#addSourceFile calls with addSourceLines in UnannotatedTests and CoreTests by inlining several test source files (AnnotatedClass, TestAnnot, Shape_Stuff, Shape_Stuff2, and unannotated/UnannotatedClass) into the test methods and deletes the corresponding test resource files. Removes the class-level @SuppressWarnings("deprecation") annotation from UnannotatedTests. No production code signatures were changed.

Possibly related PRs

  • PR #1424: Same migration of test resources from external files to inline addSourceLines in UnannotatedTests and CoreTests, converting addSourceFile usages to addSourceLines.

Suggested reviewers

  • msridhar
  • yuxincs

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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately reflects the main objective: refactoring tests to use addSourceLines and inline test data instead of external files.
Linked Issues check ✅ Passed All requirements from issue #1425 are met: deprecated addSourceFile calls replaced with addSourceLines [#1425], test data inlined into test files [#1425], @SuppressWarnings deprecation removed [#1425], and affected tests updated [#1425].
Out of Scope Changes check ✅ Passed All changes are within scope of issue #1425; PR focuses on refactoring specified test files and removing no-longer-needed external test data files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings

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.

@cobayo cobayo changed the title Fixes #1425 Refactor UnannotatedTests to use addSourceLines and inline test data Jan 2, 2026

@msridhar msridhar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution @cobayo!

Could you use text blocks instead of comma-separated strings for the test data? We plan to shift to using text blocks for test data everywhere, see #1424. You can use the changes there as an example of how the text blocks should look.

@msridhar

msridhar commented Jan 4, 2026

Copy link
Copy Markdown
Collaborator

Also @cobayo it looks like these files are used in other tests, that's why CI is failing. So you'll need to do this fix in more places for it to be mergeable.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 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 f4ca05d and 2296fda.

📒 Files selected for processing (10)
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/CapturingScopes.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/CheckAssertSupportNegativeCases.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/CheckAssertSupportPositiveCases.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwayAnonymousClass.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwayNegativeCases.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwayPositiveCases.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwayTryFinallyCases.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/OtherStuff.java
💤 Files with no reviewable changes (8)
  • nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwayPositiveCases.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwayTryFinallyCases.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/CapturingScopes.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/OtherStuff.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwayNegativeCases.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/CheckAssertSupportNegativeCases.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwayAnonymousClass.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/CheckAssertSupportPositiveCases.java
🧰 Additional context used
🧠 Learnings (7)
📓 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.
📚 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/UnannotatedTests.java
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 Learning: 2025-08-29T18:41:43.584Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 Learning: 2025-11-25T22:43:06.446Z
Learnt from: CR
Repo: uber/NullAway PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T22:43:06.446Z
Learning: Run only the tests for the main NullAway module using `./gradlew :nullaway:test` unless specifically asked to run tests in a different module

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 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:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 Learning: 2025-11-25T22:43:06.446Z
Learnt from: CR
Repo: uber/NullAway PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T22:43:06.446Z
Learning: Use the `--tests` flag with gradle to run specific test classes or methods, e.g., `./gradlew :nullaway:test --tests "com.uber.nullaway.NullAwayTest"`

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
📚 Learning: 2025-10-29T23:56:18.236Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1316
File: jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java:261-293
Timestamp: 2025-10-29T23:56:18.236Z
Learning: In NullAway's jdk-javac-plugin NullnessAnnotationSerializer, type variable bounds with annotations (e.g., `T extends Nullable Object`) are checked at their declaration sites by the typeParamHasAnnotation method for both class-level and method-level type parameters. The hasJSpecifyAnnotationDeep method is designed to check type uses (return types, parameters, etc.) and does not need a TYPEVAR case because type variable declaration bounds are already handled separately.

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
🧬 Code graph analysis (1)
nullaway/src/test/java/com/uber/nullaway/CoreTests.java (4)
nullaway/src/test/java/com/uber/nullaway/FrameworkTests.java (1)
  • SuppressWarnings (6-1309)
nullaway/src/test/java/com/uber/nullaway/ContractsTests.java (1)
  • SuppressWarnings (6-597)
nullaway/src/test/java/com/uber/nullaway/ThriftTests.java (1)
  • SuppressWarnings (6-193)
nullaway/src/test/java/com/uber/nullaway/InitializationTests.java (1)
  • SuppressWarnings (6-185)
🔇 Additional comments (10)
nullaway/src/test/java/com/uber/nullaway/CoreTests.java (8)

36-509: LGTM! Test data successfully inlined.

The migration from addSourceFile to addSourceLines with inline test data is clean and consistent with the PR objectives.


515-554: LGTM! Test data successfully inlined.

The migration to inline test data is consistent with the PR approach.


560-1557: LGTM! Multiple test data files successfully inlined.

The migration of NullAwayNegativeCases.java, OtherStuff.java, TestAnnot.java, and UnannotatedClass.java to inline sources is clean and maintains test functionality.


1563-1590: LGTM! Test data successfully inlined.


1601-1645: LGTM! Test data successfully inlined.


1857-1891: LGTM! Util.java test data successfully inlined.


2051-2190: LGTM! CapturingScopes.java test data successfully inlined.


2441-2875: LGTM! NullAwayTryFinallyCases.java test data successfully inlined.

nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java (2)

6-78: LGTM! Class annotation removed and test data successfully inlined.

The removal of the class-level @SuppressWarnings("deprecation") annotation aligns with the PR objectives, and the migration of Shape_Stuff.java, Shape_Stuff2.java, AnnotatedClass.java, and TestAnnot.java to inline sources is clean.


135-166: LGTM! UnannotatedClass.java test data successfully inlined.

The migration to inline test data is consistent with the PR approach.

@cobayo

cobayo commented Jan 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you for the guidance, @msridhar!
I have updated UnannotatedTests and CoreTests to use Java text blocks (""") and inlined the test data as suggested. The previous CI failure was caused by removing the physical test files that are no longer needed, and this commit fixes that.

Regarding other occurrences of addSourceFile in the codebase: would you like me to address all of them across the entire project in this PR to align with the new policy (#1424), or should I keep this PR focused only on the tests related to the files I've already modified?

@cobayo
cobayo requested a review from msridhar January 5, 2026 05:58
@codecov

codecov Bot commented Jan 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.37%. Comparing base (b1d1e05) to head (c957fe6).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1426   +/-   ##
=========================================
  Coverage     88.37%   88.37%           
  Complexity     2667     2667           
=========================================
  Files            97       97           
  Lines          8853     8853           
  Branches       1773     1773           
=========================================
  Hits           7824     7824           
  Misses          512      512           
  Partials        517      517           

☔ 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 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@cobayo sorry, there are some new conflicts with the master branch since we merged #1424. Could you fix? In relation to your question, let's limit this PR to these test files for now and not do the whole project. I think we'll need follow-up tasks to split up some of these tests into smaller tests, as some of the test data files are quite large. We could also split a class like CoreTests into multiple test classes, each containing the smaller tests. That could also speed up running the test suite (since Gradle will run test classes in parallel but not tests within a class). But that's all for follow up.

@cobayo cobayo changed the title Refactor UnannotatedTests to use addSourceLines and inline test data Refactor CoreTests and UnannotatedTests to use addSourceLines and inline test data Jan 6, 2026
@cobayo

cobayo commented Jan 6, 2026

Copy link
Copy Markdown
Contributor Author

@msridhar
I've resolved the conflicts with the master branch and updated the code to use text blocks for the test data in UnannotatedTests and CoreTests.

Following your suggestion, I've limited the changes to these specific test files for now. The physical test data files have been removed as they are now fully inlined. CI should be green now!

@msridhar msridhar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall this looks good. I have a couple of nitpicks on formatting. If they are for some reason too hard to fix let me know

.addSourceLines(
"NullAwayPositiveCases.java",
"""
package com.uber.nullaway.testdata;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we get the indentation of the code to always align vertically with the """ that starts the text block? I think you could do this, e.g., by highlighting the test data code in IntelliJ and doing SHIFT+TAB until it's aligned

// BUG: Diagnostic contains: passing @Nullable parameter 'q' where
return new TestAnon3(q) {};
}
}""")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, could we always have a trailing newline, so the ending """ aligns vertically with the beginning """ and we have a close paren right after? Formatting like line 552 of the file is what I'm hoping for

Refactor UnannotatedTests to inline multiple test data files

Replaced addSourceFile with addSourceLines in all test cases.

Inlined Shape_Stuff.java, Shape_Stuff2.java, AnnotatedClass.java, and TestAnnot.java.

Deleted the original source files from testdata directory.

Removed unnecessary @SuppressWarnings(deprecation) annotations.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Fix all issues with AI Agents 🤖
In @nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java:
- Around line 33-54: Fix indentation inside the Shape_Stuff2.java test text
block: remove the extra leading space before the class comment line inside the
block (the "/** to test exclusions functionality */" line) so it aligns with the
package declaration and class declaration, and adjust the final closing brace so
it aligns with the "public class Shape_Stuff2" opening (remove excessive leading
spaces before the last "}" ). Ensure inner class C and its members keep their
existing relative indentation.
- Around line 140-170: The inlined UnannotatedClass.java text block has
inconsistent indentation; fix it by aligning class members and Javadoc/method
bodies to a consistent indentation level inside class UnannotatedClass: indent
"private Object field;" and "@Nullable public Object maybeNull;" as class
members, normalize indentation of the constructor and the static methods foo()
and bar(), and remove the excessive leading spaces before the class closing
brace and the closing triple-quote so the ending brace aligns with the class
declaration and the closing """ aligns with the .addSourceLines( call. Ensure
Javadoc lines are indented to match their methods.
📜 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 84f53ae and 1c063ef.

📒 Files selected for processing (7)
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/AnnotatedClass.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/Shape_Stuff.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/TestAnnot.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/excluded/Shape_Stuff2.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/unannotated/UnannotatedClass.java
💤 Files with no reviewable changes (5)
  • nullaway/src/test/resources/com/uber/nullaway/testdata/unannotated/UnannotatedClass.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/excluded/Shape_Stuff2.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/TestAnnot.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/AnnotatedClass.java
  • nullaway/src/test/resources/com/uber/nullaway/testdata/Shape_Stuff.java
🧰 Additional context used
🧠 Learnings (6)
📚 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/CoreTests.java
  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
📚 Learning: 2025-11-25T22:43:06.446Z
Learnt from: CR
Repo: uber/NullAway PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T22:43:06.446Z
Learning: Run only the tests for the main NullAway module using `./gradlew :nullaway:test` unless specifically asked to run tests in a different module

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
📚 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:

  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
📚 Learning: 2025-08-29T18:41:43.584Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
📚 Learning: 2025-11-25T22:43:06.446Z
Learnt from: CR
Repo: uber/NullAway PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T22:43:06.446Z
Learning: Use the `--tests` flag with gradle to run specific test classes or methods, e.g., `./gradlew :nullaway:test --tests "com.uber.nullaway.NullAwayTest"`

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
📚 Learning: 2025-10-29T23:56:18.236Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1316
File: jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java:261-293
Timestamp: 2025-10-29T23:56:18.236Z
Learning: In NullAway's jdk-javac-plugin NullnessAnnotationSerializer, type variable bounds with annotations (e.g., `T extends Nullable Object`) are checked at their declaration sites by the typeParamHasAnnotation method for both class-level and method-level type parameters. The hasJSpecifyAnnotationDeep method is designed to check type uses (return types, parameters, etc.) and does not need a TYPEVAR case because type variable declaration bounds are already handled separately.

Applied to files:

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

11-32: LGTM: Migration to addSourceLines with inline test data is correct.

The refactoring successfully addresses the deprecation of addSourceFile() by:

  • Using addSourceLines() with Java text blocks for inline test data
  • Maintaining test semantics while eliminating external file dependencies
  • Making tests more self-contained and maintainable

This approach aligns with the PR objectives and modern Java testing best practices.

Also applies to: 33-54, 55-67, 68-78, 140-170


11-79: Verification confirmed: no other tests reference the deleted test data files.

The search for references to Shape_Stuff.java, Shape_Stuff2.java, AnnotatedClass.java, TestAnnot.java, and UnannotatedClass.java across the codebase returned no matches. The developer's claim that all test dependencies on the deleted files have been resolved is accurate.

@cobayo

cobayo commented Jan 6, 2026

Copy link
Copy Markdown
Contributor Author

@msridhar
Sorry for the back and forth. I realized that the scope of changes for CoreTests was becoming quite large, so I have updated my commits to focus only on UnannotatedTests and the minimum necessary changes in CoreTests to keep the build passing.

As you suggested, this keeps the PR more focused and easier to review. I’ve ensured that the specific test files I removed are no longer referenced. Ready for another look!

Fix indentation

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI Agents
In @nullaway/src/test/java/com/uber/nullaway/CoreTests.java:
- Around line 52-62: The multi-line string passed to addSourceLines for
"TestAnnot.java" is not indented to align with the opening triple-quote ("""),
so adjust the indentation of every line inside that text block to match the
column of the opening """; locate the addSourceLines call that contains
"TestAnnot.java" and re-indent the package, imports, @Retention and public
@interface TestAnnot lines to the same indentation level as the opening """
(matching style used in testGenericAnonymousInner).
- Around line 63-92: Reformat the multi-line string for "UnannotatedClass.java"
so its content lines align vertically with the opening triple-quote: remove the
extra leading spaces before the first package line and ensure internal
indentation is consistent (e.g., 2 spaces per block level) for class body,
fields, constructor, and the Javadoc/methods (foo and bar); also remove the
extra leading space before the final closing brace and the closing triple-quote
so the block matches the other text blocks in the file.
📜 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 1c063ef and 9be5ca4.

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

  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 Learning: 2025-11-25T22:43:06.446Z
Learnt from: CR
Repo: uber/NullAway PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T22:43:06.446Z
Learning: Run only the tests for the main NullAway module using `./gradlew :nullaway:test` unless specifically asked to run tests in a different module

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 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:

  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 Learning: 2025-08-29T18:41:43.584Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java

Fix indentation

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java (1)

11-170: Consider automating the indentation fixes across all text blocks.

Since multiple text blocks in both test files have the same indentation issue, would you like me to generate a comprehensive fix that addresses all the indentation inconsistencies at once? This would ensure consistent formatting across all the newly inlined test data blocks.

🤖 Fix all issues with AI Agents
In @nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java:
- Around line 55-67: Re-indent the multiline string passed to addSourceLines so
every line of the Java snippet is aligned with the opening triple-quote (""")
indentation; locate the addSourceLines call containing the "AnnotatedClass.java"
snippet and adjust the inner block (class AnnotatedClass, its Javadoc,
@TestAnnot, method foo, and statements) so leading spaces match the column of
the opening """, preserving existing content and line breaks.
- Around line 68-78: The indented Java source in the addSourceLines call for
"TestAnnot.java" is not aligned with the opening triple-quote; re-indent the
lines inside the text block so their left edge lines up with the opening """
(i.e., remove the extra leading spaces before "package
com.uber.nullaway.testdata;" and all subsequent lines) so the block's content is
vertically aligned with the opening delimiter in the addSourceLines call.
- Around line 11-32: The triple-quoted source block passed to addSourceLines for
"Shape_Stuff.java" is not indented to align with the opening """; re-indent the
entire string literal so its first line and subsequent lines align vertically
with the opening triple quotes, preserving the existing content (class
Shape_Stuff, nested class C, callee, and doBadStuff) and keeping internal
indentation relative to each other.
📜 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 9be5ca4 and c957fe6.

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

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 Learning: 2025-08-29T18:41:43.584Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 Learning: 2025-11-25T22:43:06.446Z
Learnt from: CR
Repo: uber/NullAway PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T22:43:06.446Z
Learning: Run only the tests for the main NullAway module using `./gradlew :nullaway:test` unless specifically asked to run tests in a different module

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 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:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
  • nullaway/src/test/java/com/uber/nullaway/CoreTests.java
📚 Learning: 2025-11-25T22:43:06.446Z
Learnt from: CR
Repo: uber/NullAway PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T22:43:06.446Z
Learning: Use the `--tests` flag with gradle to run specific test classes or methods, e.g., `./gradlew :nullaway:test --tests "com.uber.nullaway.NullAwayTest"`

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
📚 Learning: 2025-10-29T23:56:18.236Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1316
File: jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java:261-293
Timestamp: 2025-10-29T23:56:18.236Z
Learning: In NullAway's jdk-javac-plugin NullnessAnnotationSerializer, type variable bounds with annotations (e.g., `T extends Nullable Object`) are checked at their declaration sites by the typeParamHasAnnotation method for both class-level and method-level type parameters. The hasJSpecifyAnnotationDeep method is designed to check type uses (return types, parameters, etc.) and does not need a TYPEVAR case because type variable declaration bounds are already handled separately.

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java
🔇 Additional comments (4)
nullaway/src/test/java/com/uber/nullaway/CoreTests.java (2)

52-62: Align code indentation with the opening """.

The code within this text block should be indented to align vertically with the opening """, as requested by the maintainer. This same issue was flagged in a previous review.

Likely an incorrect or invalid review comment.


63-92: Fix indentation alignment and internal formatting.

The code within this text block should be indented to align vertically with the opening """. Additionally, the internal indentation should be consistent. This same issue was flagged in a previous review.

⛔ Skipped due to learnings
Learnt from: msridhar
Repo: uber/NullAway PR: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.
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.
nullaway/src/test/java/com/uber/nullaway/UnannotatedTests.java (2)

33-54: Clean up indentation inconsistencies in the Shape_Stuff2.java text block.

The code within this text block should be indented to align vertically with the opening """. This same issue was flagged in a previous review.

Likely an incorrect or invalid review comment.


139-170: Clean up indentation inconsistencies in the UnannotatedClass.java text block.

The code within this text block should be indented to align vertically with the opening """, and the internal indentation should be consistent. This same issue was flagged in a previous review.

⛔ Skipped due to 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: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.

@cobayo
cobayo requested a review from msridhar January 6, 2026 07:22

@msridhar msridhar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Note that this doesn't fully address #1425. That issue covers removing calls to addSourceFile everywhere in tests and replacing with addSourceLines. I checked and every @SuppressWarnings("deprecation") in NullAway code I think is due to this issue. @cobayo if you'd like to fix more of these in follow-up PRs that would be much appreciated!

@msridhar
msridhar enabled auto-merge (squash) January 6, 2026 21:03
@msridhar
msridhar merged commit 9fb90c3 into uber:master Jan 6, 2026
9 checks passed
@cobayo

cobayo commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

@msridhar

Got it! I see that there are still many instances to be fixed. I'll work on them incrementally in my next PRs. Thanks for pointing that out!

nanookclaw added a commit to nanookclaw/NullAway that referenced this pull request Apr 11, 2026
…deprecated addSourceFile

Replaces all calls to deprecated CompilationTestHelper#addSourceFile with
addSourceLines, inlining the source code as text blocks. This follows the
same pattern as PR uber#1426 which handled CoreTests and UnannotatedTests.

Changes:
- ThriftTests: Replace 1 addSourceFile call (Util.java inlined)
- Java8Tests: Replace 4 addSourceFile calls (NullAwayJava8PositiveCases,
  NullAwayJava8NegativeCases, NullAwaySuperFunctionalInterface,
  NullAwayOverrideFunctionalInterfaces all inlined)
- Remove @SuppressWarnings("deprecation") annotations from both classes
- Delete 4 now-unused testdata files for Java8Tests

Fixes uber#1425 (partial - remaining test files can be addressed in follow-up PRs)
msridhar added a commit that referenced this pull request Apr 15, 2026
…deprecated addSourceFile (#1517)

## Summary

Follow-up to #1426, continuing the migration from deprecated
`CompilationTestHelper#addSourceFile` to `addSourceLines` as described
in #1425.

## Changes

**ThriftTests.java:**
- Replace 1 `addSourceFile("testdata/Util.java")` call with
`addSourceLines`, inlining the Util.java source as a text block
- Remove `@SuppressWarnings("deprecation")` class annotation

**Java8Tests.java:**
- Replace 4 `addSourceFile` calls with `addSourceLines`:
  - `NullAwayJava8PositiveCases.java` (inlined)
  - `NullAwayJava8NegativeCases.java` (inlined)
  - `NullAwaySuperFunctionalInterface.java` (inlined)
  - `NullAwayOverrideFunctionalInterfaces.java` (inlined)
- Remove `@SuppressWarnings("deprecation")` class and method annotations
- Delete 4 now-unused testdata resource files

## Notes

- Copyright/license headers are stripped when inlining (consistent with
PR #1426 pattern)
- `Util.java` resource file is **not** deleted — it is still referenced
by
`-XepOpt:NullAway:CastToNonNullMethod=com.uber.nullaway.testdata.Util.castToNonNull`
in other test files
- Remaining test files with `addSourceFile` calls (InitializationTests,
AndroidTest, FrameworkTests, CoreTests) can be addressed in follow-up
PRs to keep reviews manageable

Fixes #1425 (partial)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **Tests**
* Modernized test infrastructure to reduce deprecation warnings and
improve code organization.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Nanook <nanookclaw@users.noreply.github.com>
Co-authored-by: Manu Sridharan <msridhar@gmail.com>
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