JamitLabs / ProjLint

Project Linter to enforce your non-code best practices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 the violations(in directory: URL) is not being used in most cases. The reason for such thing is that the URL(fileURLWithPath: relativePath) function is used to convert a String to a URL. Such initializer, when the path is relative, automatically (and silently) sets the base directory to currentDirectoryPath, 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, function URL(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 the Resource object was always returning an absolute path.
    The reason this problem has not been detected in production is because the currentDirectoryPath is the directory where the .projlint.yml lives, as there is no possibility to specify a custom path for it.