Ccodemod

codemod/spring-7-responseentity-status-value

Replace deprecated Java Spring Framework ResponseEntity#getStatusCodeValue() calls with ResponseEntity#getStatusCode().value() to preserve behavior and restore compatibility with Spring Framework 7, where getStatusCodeValue() has been removed.

javaspringspring-frameworkmigrationresponseentity
Public
0 executions

Run locally

npx codemod @codemod/spring-7-responseentity-status-value

@codemod/spring-7-responseentity-status-value

Replace deprecated Java Spring Framework ResponseEntity#getStatusCodeValue() calls with ResponseEntity#getStatusCode().value() to preserve behavior and restore compatibility with Spring Framework 7, where getStatusCodeValue() has been removed.

Installation

bash

Usage

This codemod rewrites zero-argument instance calls to getStatusCodeValue() into getStatusCode().value() when the current Java file proves the receiver is Spring's org.springframework.http.ResponseEntity or a local subclass that inherits the Spring method.

Rewritten examples:

  • responseEntity.getStatusCodeValue() -> responseEntity.getStatusCode().value()
  • service.call().getStatusCodeValue() -> service.call().getStatusCode().value() when call() is declared in the same file to return ResponseEntity
  • ((ResponseEntity<String>) value).getStatusCodeValue() -> ((ResponseEntity<String>) value).getStatusCode().value()
  • (ok ? a : b).getStatusCodeValue() -> (ok ? a : b).getStatusCode().value() when both branches resolve to Spring ResponseEntity receivers

Preserve / no-op cases:

  • Methods with the same name on non-Spring types remain unchanged.
  • Calls the codemod cannot prove are Spring ResponseEntity receivers remain unchanged.
  • Method declarations, overrides, method references, comments, and strings remain unchanged.
  • Generated sources are skipped by default. Pass --param include_generated=true to include them.

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.