Test case:
a.b(c: d?.e, f: g,
h: i)
Run with:
swiftlint lint --path ~/Desktop/test.swift --enable-all-rules
If you remove the ? it lints correctly.
Err, for some reason SourceKit only returns two parameters in that case:
{
"key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
"key.substructure" : [
{
"key.namelength" : 3,
"key.nameoffset" : 0,
"key.length" : 28,
"key.substructure" : [
{
"key.namelength" : 1,
"key.nameoffset" : 13,
"key.length" : 4,
"key.name" : "f",
"key.bodyoffset" : 16,
"key.bodylength" : 1,
"key.kind" : "source.lang.swift.expr.argument",
"key.offset" : 13
},
{
"key.namelength" : 1,
"key.nameoffset" : 23,
"key.length" : 4,
"key.name" : "h",
"key.bodyoffset" : 26,
"key.bodylength" : 1,
"key.kind" : "source.lang.swift.expr.argument",
"key.offset" : 23
}
],
"key.name" : "a.b",
"key.bodyoffset" : 4,
"key.bodylength" : 23,
"key.kind" : "source.lang.swift.expr.call",
"key.offset" : 0
}
],
"key.offset" : 0,
"key.length" : 28
}
If I remove the ?, it returns all 3:
{
"key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
"key.substructure" : [
{
"key.namelength" : 3,
"key.nameoffset" : 0,
"key.length" : 27,
"key.substructure" : [
{
"key.namelength" : 1,
"key.nameoffset" : 4,
"key.length" : 6,
"key.name" : "c",
"key.bodyoffset" : 7,
"key.bodylength" : 3,
"key.kind" : "source.lang.swift.expr.argument",
"key.offset" : 4
},
{
"key.namelength" : 1,
"key.nameoffset" : 12,
"key.length" : 4,
"key.name" : "f",
"key.bodyoffset" : 15,
"key.bodylength" : 1,
"key.kind" : "source.lang.swift.expr.argument",
"key.offset" : 12
},
{
"key.namelength" : 1,
"key.nameoffset" : 22,
"key.length" : 4,
"key.name" : "h",
"key.bodyoffset" : 25,
"key.bodylength" : 1,
"key.kind" : "source.lang.swift.expr.argument",
"key.offset" : 22
}
],
"key.name" : "a.b",
"key.bodyoffset" : 4,
"key.bodylength" : 22,
"key.kind" : "source.lang.swift.expr.call",
"key.offset" : 0
}
],
"key.offset" : 0,
"key.length" : 27
}
@keith Could you please file a Swift bug in their JIRA? 馃槵
Thanks for spotting this, I filed https://bugs.swift.org/browse/SR-5717
I'm seeing the same false positive in my code. It looks like SR-5717 was fixed by https://github.com/apple/swift/pull/11542, which seems to be included in the Swift 4.1 development snapshots.
Swift 4.1 has been released. Building my project with Xcode 9.3, I no longer get this false positive (and SwiftLint helpfully informs me of a "superfluous disable command" where I had been using swiftlint:disable:next to silence the false positive).
I believe this bug can now be closed.
馃帀
Nice. Thanks for the update.
Thanks for doing all the work here @marcelofabri !!
Most helpful comment
Thanks for doing all the work here @marcelofabri !!