A hardcoded file path is a guarantee that eventually the program will fail. It may happen because the paths on the target machine changed or because the application was deployed on an OS other than the one on which it was developed. After all, not every OS has a "C:" drive, just has not every OS has a "/home" directory. 


This rule checks for hardcoded, absolute paths in ``++Files++`` and all types of input and output streams.


== Noncompliant Code Example

----
public void readProperties() {
  File in = new File("C:/myappdir/app.properties");  // Noncompliant
}
----


== Compliant Solution

----
public void readProperties(String path) {
  File in = new File(path + "app.properties");
}
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
