rspec/rules/S1075/description.adoc

17 lines
871 B
Plaintext
Raw Normal View History

2023-10-18 11:18:09 +02:00
== Why is this an issue?
2020-06-30 12:47:33 +02:00
2023-10-18 11:18:09 +02:00
Hard-coding a URI makes it difficult to test a program for a variety of reasons:
2021-02-02 15:02:10 +01:00
2023-10-18 11:18:09 +02:00
* path literals are not always portable across operating systems
* a given absolute path may not exist in a specific test environment
* a specified Internet URL may not be available when executing the tests
* production environment filesystems usually differ from the development environment
2020-06-30 12:47:33 +02:00
In addition, hard-coded URIs can contain sensitive information, like IP addresses, and they should not be stored in the code.
2023-10-18 11:18:09 +02:00
For all those reasons, a URI should never be hard coded. Instead, it should be replaced by a customizable parameter.
2021-02-02 15:02:10 +01:00
2023-10-18 11:18:09 +02:00
Further, even if the elements of a URI are obtained dynamically, portability can still be limited if the path delimiters are hard-coded.
This rule raises an issue when URIs or path delimiters are hard-coded.