Description
What it does
Detect calls to .join
with an absolute path as an argument. This won't do what the user likely expects. join
with an absolute path will ignore the left-hand side and just use the absolute path.
For example, root.join("/bin/sh")
will return the path "/bin/sh"
.
In an ideal world, this would also detect calls like root.join(SOME_CONSTANT)
where the constant is a hardcoded absolute path, as well, but that may be harder. This would still provide value even if it only detects absolute paths specified directly in the join
call.
The lint should explain the behavior of join
, and should suggest removing the leading /
from the absolute path.
Lint Name
join_absolute_path
Category
correctness
Advantage
Removing the leading /
from the user's path will make the join create a path relative to the path given on the left-hand side of the join operation.
Drawbacks
No response
Example
some_path.join("/bin/sh")
Could be written as:
some_path.join("bin/sh")