Hardcoding an IP address into source code is a bad idea for several reasons:

Recommended Secure Coding Practices

Noncompliant Code Example

String ip = "192.168.12.42"; // Noncompliant
Socket socket = new Socket(ip, 6667);

Exceptions

No issue is reported for the following cases because they are not considered as sensitive:

See