Remove hard-coded IP addresses from comments

Proprietary

Removes hard-coded IPv4 addresses from comments when they match private IP ranges or loopback addresses. This targets IP addresses that are commented out in various comment formats:

Private IP ranges:

  • 192.168.0.0 to 192.168.255.255
  • 10.0.0.0 to 10.255.255.255
  • 172.16.0.0 to 172.31.255.255

Loopback IP range:

  • 127.0.0.0 to 127.255.255.255

Supported comment formats:

  • C-style line comments (//)
  • C-style block comments (/* */)
  • Shell/Python style comments (#)
  • XML comments (<!-- -->)
  • YAML comments (#)
  • Properties file comments (# or !)

For line comments, the entire line is removed. For block comments, only the IP address is removed.

org.openrewrite.text.RemoveHardcodedIPAddressesFromComments

Optional

If specified, replaces hard-coded IP addresses with this value. Default is 'IP_ADDRESS_REPLACED'

mod run . --recipe=org.openrewrite.text.RemoveHardcodedIPAddressesFromComments

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.