Skip to content

Files

Latest commit

 

History

History
126 lines (72 loc) · 991 Bytes

opening_brace.md

File metadata and controls

126 lines (72 loc) · 991 Bytes

Pattern: Malformed {

Issue: -

Description

Opening braces should be preceded by a single space and on the same line as the declaration.

Examples of correct code:

func abc() {
}


[].map() { $0 }


[].map({ })


if let a = b { }


while a == b { }


guard let a = b else { }


if
	let a = b,
	let c = d
	where a == c
{ }


while
	let a = b,
	let c = d
	where a == c
{ }


guard
	let a = b,
	let c = d
	where a == c else
{ }


struct Rule {}


struct Parent {
	struct Child {
		let foo: Int
	}
}

Examples of incorrect code:

func abc(){
}


func abc(){ }


[].map(){ $0 }


[].map( { } )


if let a = b{ }


while a == b{ }


guard let a = b else{ }


if
	let a = b,
	let c = d
	where a == c{ }


while
	let a = b,
	let c = d
	where a == c{ }


guard
	let a = b,
	let c = d
	where a == c else{ }


struct Rule{}


struct Rule
{
}


struct Rule

	{
}


struct Parent {
	struct Child{
		let foo: Int
	}
}