-
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
False positive on closure_parameter_position with Swift 2.3 #1019
Comments
Are you sure this isolated example triggers? I wasn't able to reproduce it. |
trivial example: if you add a () inside the completion closure, it would trigger. |
Like this? UIView.animateWithDuration(0.3, animations: {
self.disableInteractionRightView.alpha = 0
}, completion: { _ in
self.something()
}) I can't reproduce it this way as well. Can you provide a full example? |
oh, misread the issue, wrong rule, I was thinking |
@marcelofabri To be more specific about the original issue, I saw it wth my eyes in @jrmybrault 's Xcode, the warning was about a violation of the Didn't try locally on my own Xcode though. |
Maybe something else in the file is affecting this. If you could reduce to a triggering example, it would be great 💯 This rule is new in SwiftLint 0.14 which as released on Homebrew today. |
@marcelofabri We actually don't work tomorrow nor the day after (Xmas period), And idk if @jrmybrault works next week tbh 😄 but will keep that in mind |
@marcelofabri : Actually, I reproduce it only on Xcode 7.x.x, it seems fine on Xcode 8.x. I thought it could be related to spaces & indentations but the settings are identical. Xcode 7.3.1 : triggers
Xcode 8.2 : does not trigger
|
@jrmybrault Thanks for doing this! I'm downloading Xcode 7.3.1 right now and will verify it later. My theory is that SourceKit is returning different structures for this file. |
The structures are a bit different, which may explain the false positive: Xcode 7.3.1{
"key.namelength": 30,
"key.nameoffset": 83,
"key.bodylength": 161,
"key.accessibility": "source.lang.swift.accessibility.internal",
"key.length": 199,
"key.substructure": [{
"key.nameoffset": 0,
"key.typename": "Bool",
"key.length": 14,
"key.name": "animated",
"key.kind": "source.lang.swift.decl.var.parameter",
"key.namelength": 0,
"key.offset": 98
}, {
"key.offset": 117,
"key.nameoffset": 117,
"key.length": 30,
"key.name": "super.viewWillAppear",
"key.bodyoffset": 138,
"key.kind": "source.lang.swift.expr.call",
"key.namelength": 20,
"key.bodylength": 8
}, {
"key.bodylength": 95,
"key.nameoffset": 150,
"key.substructure": [{
"key.offset": 177,
"key.nameoffset": 0,
"key.length": 3,
"key.bodyoffset": 177,
"key.bodylength": 3,
"key.kind": "source.lang.swift.decl.var.parameter",
"key.namelength": 0
}, {
"key.offset": 182,
"key.nameoffset": 182,
"key.length": 41,
"key.name": "animations",
"key.bodyoffset": 194,
"key.kind": "source.lang.swift.decl.var.parameter",
"key.namelength": 10,
"key.bodylength": 29
}, {
"key.bodylength": 35,
"key.nameoffset": 225,
"key.substructure": [{
"key.typename": "_",
"key.nameoffset": 0,
"key.kind": "source.lang.swift.decl.var.parameter",
"key.length": 1,
"key.namelength": 0,
"key.offset": 239
}],
"key.length": 47,
"key.name": "completion",
"key.bodyoffset": 237,
"key.kind": "source.lang.swift.decl.var.parameter",
"key.offset": 225,
"key.namelength": 10
}],
"key.length": 123,
"key.name": "UIView.animateWithDuration",
"key.bodyoffset": 177,
"key.kind": "source.lang.swift.expr.call",
"key.offset": 150,
"key.namelength": 26
}],
"key.name": "viewWillAppear(_:)",
"key.bodyoffset": 115,
"key.attributes": [{
"key.attribute": "source.decl.attribute.override"
}],
"key.kind": "source.lang.swift.decl.function.method.instance",
"key.offset": 78
} Xcode 8.2.1{
"key.namelength": 32,
"key.nameoffset": 83,
"key.bodylength": 164,
"key.accessibility": "source.lang.swift.accessibility.internal",
"key.length": 204,
"key.substructure": [{
"key.nameoffset": 0,
"key.typename": "Bool",
"key.length": 16,
"key.name": "animated",
"key.kind": "source.lang.swift.decl.var.parameter",
"key.namelength": 0,
"key.offset": 98
}, {
"key.offset": 119,
"key.nameoffset": 119,
"key.length": 30,
"key.name": "super.viewWillAppear",
"key.bodyoffset": 140,
"key.kind": "source.lang.swift.expr.call",
"key.namelength": 20,
"key.bodylength": 8
}, {
"key.bodylength": 110,
"key.nameoffset": 152,
"key.substructure": [{
"key.offset": 167,
"key.nameoffset": 167,
"key.length": 17,
"key.name": "withDuration",
"key.bodyoffset": 181,
"key.kind": "source.lang.swift.expr.argument",
"key.namelength": 12,
"key.bodylength": 3
}, {
"key.offset": 186,
"key.nameoffset": 186,
"key.length": 39,
"key.name": "animations",
"key.bodyoffset": 198,
"key.kind": "source.lang.swift.expr.argument",
"key.namelength": 10,
"key.bodylength": 27
}, {
"key.bodylength": 38,
"key.nameoffset": 227,
"key.substructure": [{
"key.nameoffset": 0,
"key.kind": "source.lang.swift.decl.var.parameter",
"key.namelength": 0,
"key.offset": 241,
"key.length": 1
}],
"key.length": 50,
"key.name": "completion",
"key.bodyoffset": 239,
"key.kind": "source.lang.swift.expr.argument",
"key.offset": 227,
"key.namelength": 10
}],
"key.length": 126,
"key.name": "UIView.animate",
"key.bodyoffset": 167,
"key.kind": "source.lang.swift.expr.call",
"key.offset": 152,
"key.namelength": 14
}],
"key.name": "viewWillAppear(_:)",
"key.bodyoffset": 117,
"key.attributes": [{
"key.attribute": "source.decl.attribute.override"
}],
"key.kind": "source.lang.swift.decl.function.method.instance",
"key.offset": 78
} Note that in 8.x, the parameters are inside a Here're the violations that were trigged:
|
Hey,
the following code triggers a parameter position violation for the completion closure :
Do you have any idea why ?
The text was updated successfully, but these errors were encountered: