Warn about unneeded suppressions in tests#7751
Conversation
…y into warn-unneeded-in-tests
…y into warn-unneeded-in-tests
…unneeded-in-tests
…y into warn-unneeded-in-tests
…y into warn-unneeded-in-tests
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis 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 Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
checker/jtreg/index/UnneededSuppressionsTest.outis excluded by!**/*.out
📒 Files selected for processing (43)
checker/tests/calledmethods/EnsuresCalledMethodsIfTest.javachecker/tests/index/ArrayIntro.javachecker/tests/index/UpperBoundRefinement.javachecker/tests/mustcall/PolyTests.javachecker/tests/nullness-checkcastelementtype/Issue1315.javachecker/tests/nullness/FullyQualifiedAnnotation.javachecker/tests/nullness/SuppressWarningsPartialKeys.javachecker/tests/regex/GroupCounts.javachecker/tests/regex/MyMatchResult.javachecker/tests/tainting/Issue2330.javadataflow/src/main/java/org/checkerframework/dataflow/analysis/AbstractAnalysis.javadataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseThree.javadocs/developer/new-contributor-projects.html-oldframework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerDirectoryTest.javaframework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkPerFileTest.javaframework-test/src/main/java/org/checkerframework/framework/test/CheckerFrameworkRootedTest.javaframework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.javaframework/src/main/java/org/checkerframework/framework/source/SourceChecker.javaframework/tests/all-systems/ForEach.javaframework/tests/all-systems/GenericNull.javaframework/tests/all-systems/GetClassTest.javaframework/tests/all-systems/InferAndWildcards.javaframework/tests/all-systems/InferTypeArgs.javaframework/tests/all-systems/Issue1708.javaframework/tests/all-systems/Issue1809.javaframework/tests/all-systems/Issue457.javaframework/tests/all-systems/Issue5042.javaframework/tests/all-systems/Issue759.javaframework/tests/all-systems/MissingBoundAnnotations.javaframework/tests/all-systems/PuritySubstring.javaframework/tests/all-systems/SetOfSet.javaframework/tests/all-systems/WildcardCrash.javaframework/tests/all-systems/WildcardSuper2.javaframework/tests/all-systems/java17/Figure.javaframework/tests/all-systems/java17/Issue6100.javaframework/tests/all-systems/java8inference/CollectorsToList.javaframework/tests/all-systems/java8inference/Issue1397.javaframework/tests/all-systems/java8inference/Issue1407.javaframework/tests/all-systems/java8inference/Issue1416.javaframework/tests/all-systems/java8inference/Issue6046.javaframework/tests/all-systems/java8inference/MemRefInfere.javaframework/tests/flow/Values.javajavacutil/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
|
Actionable comments posted: 0 |
…y into warn-unneeded-in-tests
|
Actionable comments posted: 0 |
Merge after #7747.