[Configuration] Allow absolute paths for `included` / `excluded`
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
In https://github.com/realm/SwiftLint/pull/3491 there has been a discussion about allowing configurations to specify absolute paths (paths starting with /) for the included / excluded paths. I suspect that this already works with the current implementation but rather by coincidence and not by explicit design. Also, it isn't documented.
I'll just quote the comment I left in https://github.com/realm/SwiftLint/pull/3491 here, proposing the same things here as I suggested there:
- Test whether specifying absolute paths always works with the current implementation. Add tests for that to SwiftLint.
- If it works without a change, I'd still put an explanation into the relevant method where the
included/excludedpath management is done. - If it doesn't work without a change, that change might be a simple one: not applying the path management in the method mentioned above for paths starting with
/. - Document the absolute path functionality in the
README.
The absolute path approach
But I think the solution you discovered for your use case (specifying an absolute path starting with
/) is great! The reason why this works is because"/foo".bridge().absolutePathRepresentation(rootDirectory: somePath)always returns"/foo".Now, without having it tested yet, I'd claim that this does not only work for your use case (some distant path), but also when specifying an absolute path to a file that lives in a directory below the configuration file. Internally, the absolute path may get transformed to a relative path, but that wouldn't break the functionality.
So I suggest the following:
- Test whether specifying absolute paths always works with the current implementation. Add tests for that to SwiftLint.
- If it works without a change, I'd still put an explanation into the relevant method where the
included/excludedpath management is done.- If it doesn't work without a change, that change might be a simple one: not applying the path management in the method mentioned above for paths starting with
/.- Document the absolute path functionality in the
README.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Source/SwiftLintFramework/Models/Configuration.swift at the included/excluded path management method linked in the issue. Test absolute paths for files below and outside the configuration directory, then document the supported behavior in README. Done means the behavior is covered by SwiftLint tests, the implementation is intentional if needed, and the README explains absolute paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100