Inspectopedia
 
2024.3

Hardcoded file separator

Warning
New
Last modified: 03 December 2024

Reports the forward (/) or backward (\) slash in a string or character literal. These characters are commonly used as file separators, and portability may suffer if they are hardcoded.

The inspection will not report backward slashes inside escape sequences and forward slashes immediately following the '<' character or immediately preceding the '>' character, as those often indicate XML or HTML tags rather than file names. Strings representing a java.util.TimeZone ID, strings that are valid regular expressions, or strings that equal IANA-registered MIME media types will not be reported either.

Example:

Use the option to include example/* in the set of recognized media types. Normally, usage of the example/* MIME media type outside of an example (e.g. in a Content-Type header) is an error.