Skip to content

Warn about unneeded suppressions in tests#7751

Open
mernst wants to merge 31 commits into
typetools:masterfrom
mernst:warn-unneeded-in-tests
Open

Warn about unneeded suppressions in tests#7751
mernst wants to merge 31 commits into
typetools:masterfrom
mernst:warn-unneeded-in-tests

Conversation

@mernst
Copy link
Copy Markdown
Member

@mernst mernst commented May 28, 2026

Merge after #7747.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 29d43fb8-f1c4-4a5f-841e-68b244056140

📥 Commits

Reviewing files that changed from the base of the PR and between 661030d and b35090e.

📒 Files selected for processing (3)
  • docs/manual/introduction.tex
  • docs/manual/warnings.tex
  • framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java

📝 Walkthrough

Walkthrough

This PR refactors suppression handling in SourceChecker (removing related constants and changing warnUnneededSuppressions/shouldSuppress/messageKeyMatches), enables -AwarnUnneededSuppressions in per-file and per-directory test runners, and updates many @SuppressWarnings annotations across test files (removals, narrowing, and replacements). It also adds a new purity test class and includes minor supporting changes in BaseTypeVisitor, dataflow, javacutil, and documentation.

Possibly related PRs

  • typetools/checker-framework#7650: The main PR removes @SuppressWarnings("calledmethods") from a called-methods test (EnsuresCalledMethodsIfTest.isOpen), which aligns with the retrieved PR’s changes to the called-methods checker’s suppression-prefix configuration (CalledMethodsChecker / related calledmethods alias handling).

Suggested reviewers

  • smillst
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 51.85% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java`:
- Around line 2501-2503: Remove the unconditional System.out.printf trace in
SourceChecker (the line printing checkerPrefixes and
Arrays.toString(suppressWarningsStrings)); instead either delete the print
entirely or, if the information must be emitted, report it through the
compiler/diagnostic pipeline (e.g., use processingEnv.getMessager().printMessage
or the checker's logging facility) and guard it behind the existing
debug/verbose flag so it doesn't bypass diagnostics; locate the printf in class
SourceChecker and remove/replace it so output respects the diagnostic/reporting
system.
- Around line 2509-2526: The code path for reporting unneeded suppressions skips
bare message-key fragments like "generic.argument" because it only handles
checker prefixes and "prefix:key" forms; update the logic around
suppressWarningsString in SourceChecker (the block that currently checks
checkerPrefixes and colonPos) to also detect unprefixed message-key fragments
when the require-prefix option is disabled (the same behavior used by
shouldSuppress(...)). When require-prefix-for-warning-suppressions is false,
treat an unprefixed fragment that would not actually suppress anything as an
unneeded suppression and call reportUnneededSuppression(tree,
suppressWarningsString); reuse or mirror the same check used by
shouldSuppress(...) so behavior is consistent with that method.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e8acf042-b331-422a-8399-c6706441bb8c

📥 Commits

Reviewing files that changed from the base of the PR and between 227974f and 1bc7cb5.

⛔ Files ignored due to path filters (1)
  • checker/jtreg/index/UnneededSuppressionsTest.out is excluded by !**/*.out
📒 Files selected for processing (43)
  • checker/tests/calledmethods/EnsuresCalledMethodsIfTest.java
  • checker/tests/index/ArrayIntro.java
  • checker/tests/index/UpperBoundRefinement.java
  • checker/tests/mustcall/PolyTests.java
  • checker/tests/nullness-checkcastelementtype/Issue1315.java
  • checker/tests/nullness/FullyQualifiedAnnotation.java
  • checker/tests/nullness/SuppressWarningsPartialKeys.java
  • checker/tests/regex/GroupCounts.java
  • checker/tests/regex/MyMatchResult.java
  • checker/tests/tainting/Issue2330.java
  • dataflow/src/main/java/org/checkerframework/dataflow/analysis/AbstractAnalysis.java
  • dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseThree.java
  • docs/developer/new-contributor-projects.html-old
  • framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerDirectoryTest.java
  • framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerFileTest.java
  • framework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkRootedTest.java
  • framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java
  • framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java
  • framework/tests/all-systems/ForEach.java
  • framework/tests/all-systems/GenericNull.java
  • framework/tests/all-systems/GetClassTest.java
  • framework/tests/all-systems/InferAndWildcards.java
  • framework/tests/all-systems/InferTypeArgs.java
  • framework/tests/all-systems/Issue1708.java
  • framework/tests/all-systems/Issue1809.java
  • framework/tests/all-systems/Issue457.java
  • framework/tests/all-systems/Issue5042.java
  • framework/tests/all-systems/Issue759.java
  • framework/tests/all-systems/MissingBoundAnnotations.java
  • framework/tests/all-systems/PuritySubstring.java
  • framework/tests/all-systems/SetOfSet.java
  • framework/tests/all-systems/WildcardCrash.java
  • framework/tests/all-systems/WildcardSuper2.java
  • framework/tests/all-systems/java17/Figure.java
  • framework/tests/all-systems/java17/Issue6100.java
  • framework/tests/all-systems/java8inference/CollectorsToList.java
  • framework/tests/all-systems/java8inference/Issue1397.java
  • framework/tests/all-systems/java8inference/Issue1407.java
  • framework/tests/all-systems/java8inference/Issue1416.java
  • framework/tests/all-systems/java8inference/Issue6046.java
  • framework/tests/all-systems/java8inference/MemRefInfere.java
  • framework/tests/flow/Values.java
  • javacutil/src/main/java/org/checkerframework/javacutil/ElementUtils.java
💤 Files with no reviewable changes (24)
  • checker/tests/regex/GroupCounts.java
  • checker/tests/tainting/Issue2330.java
  • framework/tests/all-systems/MissingBoundAnnotations.java
  • checker/tests/index/ArrayIntro.java
  • framework/tests/all-systems/java17/Figure.java
  • dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseThree.java
  • framework/tests/all-systems/Issue1708.java
  • framework/tests/all-systems/java8inference/CollectorsToList.java
  • framework/tests/flow/Values.java
  • framework/tests/all-systems/Issue457.java
  • framework/tests/all-systems/InferAndWildcards.java
  • checker/tests/calledmethods/EnsuresCalledMethodsIfTest.java
  • framework/tests/all-systems/java8inference/MemRefInfere.java
  • checker/tests/index/UpperBoundRefinement.java
  • dataflow/src/main/java/org/checkerframework/dataflow/analysis/AbstractAnalysis.java
  • framework/tests/all-systems/GetClassTest.java
  • framework/tests/all-systems/java17/Issue6100.java
  • checker/tests/mustcall/PolyTests.java
  • checker/tests/regex/MyMatchResult.java
  • framework/tests/all-systems/java8inference/Issue1397.java
  • framework/tests/all-systems/java8inference/Issue1407.java
  • framework/tests/all-systems/java8inference/Issue1416.java
  • framework/tests/all-systems/Issue5042.java
  • checker/tests/nullness/FullyQualifiedAnnotation.java

Comment thread framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@smillst smillst self-assigned this May 29, 2026
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.

2 participants