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.
# @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
# Install from registry
codemod run @codemod/spring-7-responseentity-status-value
# Or run locally
codemod run -w workflow.yaml
```
## 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
# Test the transformation
pnpm test
# Validate the workflow
npx codemod workflow validate -w .
# Include generated sources explicitly
npx codemod workflow run -w . -t /path/to/project --param include_generated=true
# Publish to registry
codemod login
codemod publish
```
## License
MIT