There are a bunch of Drupal code check tools about the place (and then plenty more generic PHP ones). These are a few ... I should write them up in more detail?
- https://mglaman.dev/blog/drupal-check-and-phpstan-drupal-are-drupal-9-and-php-8-ready
- https://github.com/mglaman/phpstan-drupal
- https://github.com/mglaman/drupal-check
- https://mortenson.coffee/blog/drupal-security-testing-everyone/
- https://github.com/mortenson/psalm-plugin-drupal
- https://www.palantir.net/blog/jumpstart-your-drupal-9-upgrade-drupal-rector
- https://github.com/palantirnet/drupal-rector
- https://github.com/phpro/grumphp/