spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Improve the deprecation experience for ContentResultMatchersDsl.json

Open jtaub opened this issue 2 months ago • 0 comments

Problem Statement

It can be tedious to fix all of the deprecation warnings you get from using json(jsonContent, strict = true). It's not as easy as a find-and-replace, because it requires an import. Also, in my experience, an AI agent will be extremely likely to mess it up somehow (at least Copilot on a large project).

Solution

The Kotlin @Deprecation annotation has support for automatically replacing deprecated code with the new, supported code. I have modified the annotation on this method so that users can automatically upgrade.

Testing evidence

Here are some screenshots showing how this works in Intellij Idea:

  1. Original deprecated code. Screenshot From 2025-09-25 10-27-43

  2. The deprecation message now has a button you can click to replace the code. Screenshot From 2025-09-25 10-27-52

  3. After performing the automatic replacement. Note that the code compiles, but has a warning. Screenshot From 2025-09-25 10-28-05

  4. Intellij offers to automatically fix the warning. This can be applied to the entire file or project at once if there are multiple occurrences. Screenshot From 2025-09-25 10-28-18

  5. Done. Screenshot From 2025-09-25 10-28-29

jtaub avatar Sep 25 '25 14:09 jtaub