When a path contains '.' or '..' the violation does not show properly in Xcode
acecilia opened this issue · comments
-
For showing the errors on Xcode, the printed paths should be absolute and not contain
.
or..
paths. -
The
directory
parameter in theviolations(in directory: URL)
is not being used in most cases. The reason for such thing is that theURL(fileURLWithPath: relativePath)
function is used to convert aString
to aURL
. Such initializer, when the path is relative, automatically (and silently) sets the base directory tocurrentDirectoryPath
, leading to an absolute path equal to:URL(fileURLWithPath: relativePath) = currentDirectoryPath + relativePath
Seems that this is wrong: the path should be relative to the
directory
parameter. Thus, functionURL(fileURLWithPath: relativePath, relativeTo: directory)
should be used (only available from.macOS(.v10_11)
).The reason this problem has not been detected in the tests is because the
path
property in theResource
object was always returning an absolute path.
The reason this problem has not been detected in production is because thecurrentDirectoryPath
is the directory where the.projlint.yml
lives, as there is no possibility to specify a custom path for it.