I like having my opening braces on their own line:
if codingStyle.isOldSchool
{
print("I relate to that!")
}
else
{
print("I respect that!")
}
I'd love to be able to configure the opening_brace
rule to enforce this style. I can look into submitting a patch, but wanted to know if this is something already on your radar...
I don't think we're tracking this anywhere, but making OpeningBraceRule
be configurable by mode (maybe newline: true
or mode: same_line
/mode: new_line
) is fine by me! :+1:
+1 for configurable openingBraceRule
.
I want to write also closures for arrays or no-argument-label functions like this:
let a1 = [
"a",
{ "b" }()]
let a2 = [
"a",
{
let b = "b"
return b
}()]
func f(_ x: String, _ y: () -> String) -> [String] {
return [x, y()]
}
let a3 = f(
"a",
{ return "b" })
let a4 = f(
"a",
{
let b = "b"
return b
})
Currently, swiftlint autocorrect
with this rule changes the above to this (the declaration of f(_: _:)
is fine for me):
let a1 = [
"a", { "b" }()]
let a2 = [
"a", {
let b = "b"
return b
}()]
func f(_ x: String, _ y: () -> String) -> [String] {
return [x, y()]
}
let a3 = f(
"a", { return "b" })
let a4 = f(
"a", {
let b = "b"
return b
})
Any news about the rule being configurable?
Most helpful comment
I don't think we're tracking this anywhere, but making
OpeningBraceRule
be configurable by mode (maybenewline: true
ormode: same_line
/mode: new_line
) is fine by me! :+1: