-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Swiftlint analyzer fails when the app's Display Name contains a blank #3021
Comments
Thanks for taking the time to create a project to reproduce the issue. |
Hi There. I can confirm I hit the same issue, but in my case changing the BUNDLE_DISPLAY_NAME wasn't enough, I also had to change the target name (which IMHO makes more sense) to make SwiftLint analyze work. Config: SwiftLint 0.38.2. |
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions! |
This issue is still present in v0.41.0 and should not be closed, IMO |
The issue is that Doing something like
(splitting by spaces not preceded by a "\" and then replacing "\" with "") solves the problem. EDIT: split(usingRegex) would have to be implemented of course. I have a version of it found on StackOverflow that I'm really not happy with which works but is bad, hence not submitting this as a PR. |
This introduces another bug. It appears that some the \s in compiler arguments is required as removing them all breaks the sourcekitten index query for some files |
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions! |
This issue is still present in v0.42.0 and should not be closed, IMO |
This can be worked around by using the |
How would I generate such compilation database file using xcodebuild? I've tried using
in the example project I've linked, but this still outputs
|
If the the compilation database is empty, maybe that's a bug or limitation in xcpretty? Maybe it fails for the same reason SwiftLint is failing here (the space in the scheme name)? Maybe this tool works? https://github.com/jerrymarino/XcodeCompilationDatabase |
Thanks for the pointer. The tool you've linked does indeed produce a
This seems to be a bug in the parser for the compilation database, if I understand the documentation correctly - |
Is there any chance you could share step-by-step instructions to reproduce this? It’d be easier for me to help you if have a sample project to start debugging with. |
Sure. I've updated the https://github.com/gereons/SwiftLintBug2 repo, simply clone it and run the enclosed |
Thanks for doing that, so here's the compilation database format SwiftLint is expecting: [
{
"arguments": [
"swiftc",
"..."
],
"file": "Modules/Module1/Sources/Source1.swift"
},
{
"arguments": [
"swiftc",
"..."
],
"file": "Modules/Module1/Sources/Source2.swift"
}
] And here's what's produced by [
{
"command": " /Applications/Xcode-12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file ...",
"file": "/full/path/to/project/SwiftLintBug2/SwiftLintTest/AppDelegate.swift",
"directory": ""
},
{
"command": " /Applications/Xcode-12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c ...",
"file": "/full/path/to/project/SwiftLintBug2/SwiftLintTest/ExplicitSelf.swift",
"directory": ""
}
] There are lots of differences:
According to clang's compilation database format, either the
I'll see if parsing the |
It seems that SourceKit isn't satisfied if you give it It logs these errors:
And if I filter these out: let unsupportedArguments = [
"-primary-file",
"-emit-module-doc-path",
"-emit-dependencies-path",
"-emit-reference-dependencies-path",
"-enable-objc-interop",
"-serialize-debugging-options",
"-enable-anonymous-context-mangled-names",
"-target-sdk-version",
"-index-system-modules"
]
arguments.removeAll(where: unsupportedArguments.contains)
let unsupportedOptions = ["-serialize-diagnostics-path"]
for option in unsupportedOptions {
if let optionIndex = arguments.firstIndex(of: option) {
arguments.remove(at: optionIndex) // Option parameter
arguments.remove(at: optionIndex) // Option value
}
} the analysis appears to run without errors but produces no results:
|
I found a fix for the initial issue you reported, I should have a PR up later today. |
@gereons @DimDL @stephengroombbc can you please confirm that #3549 fixes this issue in your projects? |
Works for me 🎉 |
Thanks for checking! I've merged the fix to master. |
New Issue Checklist
Describe the bug
I'm running
swiftlint analyze
with ruleexplicit_self
enabled in my project: https://github.com/gereons/SwiftLintBug2 (use the enclosedlint.sh
to reproduce).Expected result: swiftlint reports the violations
Actual result: swiftlint does not analyze any files
Instead of the expected output of
Opening the .xcodeproj and removing the blank from the app's "Display Name" makes swiftlint work again.
Swiftlint version: 0.38.1, installed via homebrew
Xcode version: 11.3
The text was updated successfully, but these errors were encountered: