-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for passing multiple paths to swiftlint lint and autocorrect #1191
Conversation
quiet: options.quiet, useScriptInputFiles: options.useScriptInputFiles, | ||
cache: cache, parallel: true, visitorBlock: visitorBlock) | ||
} | ||
|
||
// MARK: AutoCorrect Command | ||
|
||
init(options: AutoCorrectOptions) { | ||
self.init(commandLinePath: options.configurationFile, rootPath: options.path, quiet: options.quiet) | ||
self.init(commandLinePath: options.configurationFile, rootPath: "", quiet: options.quiet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is temporary to get this to compile and test the multiple paths changes.
@@ -45,7 +45,7 @@ private func cacheURL(options: LintOptions, configuration: Configuration) -> URL | |||
} | |||
|
|||
private func defaultCacheURL(options: LintOptions) -> URL { | |||
let rootPath = options.path.bridge().absolutePathRepresentation() | |||
let rootPath = ""//options.path.bridge().absolutePathRepresentation() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is temporary to get this to compile and test the multiple paths changes.
Generated by 🚫 Danger |
In terms of caching, its hash is used as the default cache file name. |
Yep. Sorry that TODO is poorly worded. I mean that I'm not sure that it has any meaning in this context. There isn't a useful |
Does that seem reasonable? Or is there some way I'm missing that caching behavior should be preserved in this instance? |
I think either disabling or concatenating all files before getting the hash would be ok. |
Okay thanks! I went with concatenating all the files to start. If we're okay dropping |
IMHO it'd be better if we could keep |
@@ -45,15 +45,15 @@ private func cacheURL(options: LintOptions, configuration: Configuration) -> URL | |||
} | |||
|
|||
private func defaultCacheURL(options: LintOptions) -> URL { | |||
let rootPath = options.path.bridge().absolutePathRepresentation() | |||
let cacheSignature = options.paths.map { $0.bridge().absolutePathRepresentation() }.joined(separator: "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""
is the default separator, you should use just .joined()
(see #1093)
Okay! I've been thinking about concatenating the paths as a cache signature, and it feels a bit odd to me. It seems like it'd be better to disable and say up front that a cache path should be provided, which I think would avoid inconsistent/unexpected caching behavior. |
That is, only for the case of multiple paths. |
Seems good for me! |
cf02c33
to
2f61ea8
Compare
Where do I find the tests that test CLI args? In Xcode, I only see the ones that test SwiftLintFramework. |
There're no tests for this 🙃 |
Ha! Well, there is the note from Danger that says:
I'm guessing this is referring to running |
Oh I see it's just there in the Dangerfile. Hm okay. Any recommendations then? I could file a task to include some smoke tests for basic CLI options? |
Codecov Report
@@ Coverage Diff @@
## master #1191 +/- ##
==========================================
- Coverage 92.16% 92.02% -0.15%
==========================================
Files 292 292
Lines 14738 14763 +25
==========================================
+ Hits 13584 13585 +1
- Misses 1154 1178 +24
Continue to review full report at Codecov.
|
Good idea! This seems good to me, but I'd like to get a 👍 from @jpsim on this since it deals with the CLI |
Filed #1213 |
d4009ef
to
c9098ac
Compare
We need to fix our caching strategy before we do this. We need to encapsulate all the things that can affect the cache. |
Is there an open issue that summarizes the issues and/or possible solutions? I have some thoughts after working on this, but I think it'd be best to chime in there. |
@marcelofabri or @jpsim could either of you open a mega thread/issue? |
#1184 should be that umbrella issue |
Updated to only do automatic caching for single directories. Does that make this a breaking change? |
Hi @benasher44, sorry this has been on hiatus for a while. I'd like to see us fully address our caching model (#1184) before we make more changes that could affect it. |
@jpsim no problem! I'd appreciate another ping here once it's resolved, and then I'll rebase and get this PR back in order. Thanks! |
This could be revisited now that #1530 was merged |
Awesome! Will try to revive it this week! Thanks! |
537295e
to
7452799
Compare
@marcelofabri I've updated with master, and I think this is getting close to being ready to go. With caching issues being resolved, this is definitely more straightforward. The next thing to figure out is |
1e43731
to
454eff1
Compare
This will be awesome. Looking forward to seeing it merge. |
Is there any appetite for reviving this one? Happy to resolve the conflicts if it's no longer on @benasher44's radar. |
I'll take a crack at updating this PR this week |
454eff1
to
09b7956
Compare
Okay this is working again. I don't feel good about having no tests. Any advice on the testing front? |
f197981
to
fa9f6e6
Compare
Works great for me! The output for
|
I think there might also be a problem with using --path now? |
@esteluk thanks for that great feedback! I believe I've fixed the bug you found, so it'd be great if you could give this latest update another go. For the help message issue, I've filed an issue on Commandant: Carthage/Commandant/issues/128 |
Sorry, had a play and it seems to work for my purposes at least! Not sure if the maintainers can take another look? :) |
I think this is a good time to merge this @benasher44. Sorry for the massive inexcusable delay. Mind rebasing first to address the merge conflict? Thanks! |
} else { | ||
allPaths = paths | ||
} | ||
return self.init(paths: Array(allPaths), configurationFile: configurationFile, useScriptInputFiles: useScriptInputFiles, quiet: quiet, forceExclude: forceExclude, format: format, cachePath: cachePath, ignoreCache: ignoreCache, useTabs: useTabs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need to copy allPaths
into a new array here. s/Array(allPaths)/allPaths/
} else { | ||
allPaths = paths | ||
} | ||
return self.init(paths: Array(allPaths), useSTDIN: useSTDIN, configurationFile: configurationFile, strict: strict, lenient: lenient, forceExclude: forceExclude, useScriptInputFiles: useScriptInputFiles, benchmark: benchmark, reporter: reporter, quiet: quiet, cachePath: cachePath, ignoreCache: ignoreCache, enableAllRules: enableAllRules) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need to copy allPaths
into a new array here. s/Array(allPaths)/allPaths/
eedbcd8
to
32e8c5b
Compare
Thanks, @benasher44 🎉 |
🎉 🎉 Thanks for your help @marcelofabri and @jpsim!! |
This implements #810:
TODO:
rootPath
mean now (especially in terms of caching) when multiple files are passed? (disabled with a warning)--path
option? (decided to keep)This + pre-commit/pre-commit#467 (personal motivation for this PR) + hooks.yaml (maybe in a follow up PR) makes this work with pre-commit using SwiftPM. I've tested this branch locally with pre-commit, and it works great!
I'd appreciate thoughts and feedback on the above TODOs and existing changes :)