@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()whencall()is declared in the same file to returnResponseEntity((ResponseEntity<String>) value).getStatusCodeValue()->((ResponseEntity<String>) value).getStatusCode().value()(ok ? a : b).getStatusCodeValue()->(ok ? a : b).getStatusCode().value()when both branches resolve to SpringResponseEntityreceivers
Preserve / no-op cases:
- Methods with the same name on non-Spring types remain unchanged.
- Calls the codemod cannot prove are Spring
ResponseEntityreceivers remain unchanged. - Method declarations, overrides, method references, comments, and strings remain unchanged.
- Generated sources are skipped by default. Pass
--param include_generated=trueto include them.
Development
bash
License
MIT