Showing 103 of 106 total issues
Multiline comment should end with whitespace Open
**/
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Line should not have any trailing whitespace Open
- Read upRead up
- Exclude checks
trailing-whitespace
Flag whitespace after the last non-whitespace character on each line until the newline.
Preferred
let number = 42¬
Not Preferred
let number = 42••¬
Initializer expression should not be enclosed within parentheses Open
let eventPayload: ProtobufStruct? = (
- Read upRead up
- Exclude checks
redundant-parentheses
Control flow constructs (if
, else if
, switch
, for
, while
, repeat-while
, and guard
statements), Exception handling constructs (throw
, and do/catch
statements), and Initializers (array
, dictionary
, initializer patterns
) should not be enclosed in parentheses.
Additionally, method calls with no parameters and a trailing closure should not have empty parentheses following the method name.
Control flow constructs
- if, else if statement
Preferred
if SomeCondition {
} else if SomeOtherCondition {
}
Not Preferred
if (SomeCondition) {
} else if (SomeOtherCondition) {
}
- switch statement
Preferred
switch SomeData {
default:
break
}
Not Preferred
switch (SomeData) {
default:
break
}
- for loop
Preferred
for var i = 0; i < 10; i+=1 {
}
Not Preferred
for (var i = 0; i < 10; i+=1) {
}
- while loop
Preferred
while SomeCondition {
}
Not Preferred
while (SomeCondition) {
}
- repeat-while loop
Preferred
repeat {
} while SomeCondition
Not Preferred
repeat {
} while (SomeCondition)
- guard clause
Preferred
guard true else { }
Not Preferred
guard (true) else { }
Exception handling constructs
- do/catch statement
Preferred
do {
} catch SomeException {
}
Not Preferred
do {
} catch (SomeException) {
}
- throw statement
Preferred
throw SomeException
Not Preferred
throw (SomeException)
Initializers
- array items
Preferred
var shoppingList: [String] = ["Eggs", "Milk"]
Not Preferred
var shoppingList: [String] = [("Eggs"), ("Milk")]
- dictionary items
Preferred
var airports: [String: String] = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]
Not Preferred
var airports: [String: String] = [("YYZ"): ("Toronto Pearson"), ("DUB"): ("Dublin")]
- initializer patterns
Preferred
var x: Int = 2
var y: String = "Sleekbyte"
var x = 2
Not Preferred
var x: Int = (2)
var y: String = ("Sleekbyte")
var x = (2)
Method calls
Preferred
items.map {
item in item.transform()
}
Not Preferred
items.map() {
item in item.transform()
}
Single-line comment should start with whitespace Open
//// Objects
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Function should have at least one blank line before it Open
public static func now() -> TemporalInstant {
- Read upRead up
- Exclude checks
function-whitespace
Every function and method declaration should have one blank line before and after itself. An exception to this rule are functions that are declared at the start of a file (only need one blank line after their declaration) or at the end of a file (only need one blank line before their declaration). Comments immediately before a function declaration (no blank lines between them and the function) are considered to be part of the declaration.
Preferred
func function1() {
var text = 1
var text = 2
}
function1()
// a comment
func function2() {
// something goes here
}
struct SomeStruct {
func function3() {
// something goes here
}
func function4() {
// something else goes here
};
}
func function5() {
// something goes here
}
Not Preferred
func function1() {
var text = 1
var text = 2
}
function1()
// a comment
func function2() {
// something goes here
}
struct SomeStruct {
func function3() {
// something goes here
}
func function4() {
// something else goes here
};
}
func function5() {
// something goes here
}
Single-line comment should start with whitespace Open
//// Generic
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Multiline comment should end with whitespace Open
**/
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Multiline comment should end with whitespace Open
**/
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Multiline comment should end with whitespace Open
**/
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Single-line comment should start with whitespace Open
//// Client Bindings
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Single-line comment should start with whitespace Open
//// Shop Service
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Single-line comment should start with whitespace Open
//// Checkin Service
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Multiline comment should end with whitespace Open
**/
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Function should have at least one blank line after it Open
}
- Read upRead up
- Exclude checks
function-whitespace
Every function and method declaration should have one blank line before and after itself. An exception to this rule are functions that are declared at the start of a file (only need one blank line after their declaration) or at the end of a file (only need one blank line before their declaration). Comments immediately before a function declaration (no blank lines between them and the function) are considered to be part of the declaration.
Preferred
func function1() {
var text = 1
var text = 2
}
function1()
// a comment
func function2() {
// something goes here
}
struct SomeStruct {
func function3() {
// something goes here
}
func function4() {
// something else goes here
};
}
func function5() {
// something goes here
}
Not Preferred
func function1() {
var text = 1
var text = 2
}
function1()
// a comment
func function2() {
// something goes here
}
struct SomeStruct {
func function3() {
// something goes here
}
func function4() {
// something else goes here
};
}
func function5() {
// something goes here
}
Multiline comment should end with whitespace Open
**/
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Line should not have any trailing whitespace Open
- Read upRead up
- Exclude checks
trailing-whitespace
Flag whitespace after the last non-whitespace character on each line until the newline.
Preferred
let number = 42¬
Not Preferred
let number = 42••¬
Function should have at least one blank line after it Open
func prepare() { /* default: no-op */ }
- Read upRead up
- Exclude checks
function-whitespace
Every function and method declaration should have one blank line before and after itself. An exception to this rule are functions that are declared at the start of a file (only need one blank line after their declaration) or at the end of a file (only need one blank line before their declaration). Comments immediately before a function declaration (no blank lines between them and the function) are considered to be part of the declaration.
Preferred
func function1() {
var text = 1
var text = 2
}
function1()
// a comment
func function2() {
// something goes here
}
struct SomeStruct {
func function3() {
// something goes here
}
func function4() {
// something else goes here
};
}
func function5() {
// something goes here
}
Not Preferred
func function1() {
var text = 1
var text = 2
}
function1()
// a comment
func function2() {
// something goes here
}
struct SomeStruct {
func function3() {
// something goes here
}
func function4() {
// something else goes here
};
}
func function5() {
// something goes here
}
Multiline comment should end with whitespace Open
**/
- Read upRead up
- Exclude checks
comment-whitespace
Prefer at least one whitespace character after a comment opening symbol (//
, ///
, /*
, or /**
) and at least one whitespace character before a comment closing symbol (*/
).
Preferred
// This is a comment
/// This is a documentation comment
/* This is a
multi-line comment */
/* This is a
multi-line comment
*/
/** This is a
documentation multi-line
comment
*/
Not Preferred
//This is a comment
///This is a documentation comment
/*This is a
multi-line comment*/
/**This is a multi-line
documentation comment */
Function should have at least one blank line before it Open
fileprivate func resolveSearchContext(method: SearchEvent,
- Read upRead up
- Exclude checks
function-whitespace
Every function and method declaration should have one blank line before and after itself. An exception to this rule are functions that are declared at the start of a file (only need one blank line after their declaration) or at the end of a file (only need one blank line before their declaration). Comments immediately before a function declaration (no blank lines between them and the function) are considered to be part of the declaration.
Preferred
func function1() {
var text = 1
var text = 2
}
function1()
// a comment
func function2() {
// something goes here
}
struct SomeStruct {
func function3() {
// something goes here
}
func function4() {
// something else goes here
};
}
func function5() {
// something goes here
}
Not Preferred
func function1() {
var text = 1
var text = 2
}
function1()
// a comment
func function2() {
// something goes here
}
struct SomeStruct {
func function3() {
// something goes here
}
func function4() {
// something else goes here
};
}
func function5() {
// something goes here
}
File should terminate with exactly one newline character ('\n') Open
- Read upRead up
- Exclude checks
terminating-newline
Verify that source files terminate with exactly one \n
character. This ensures that the last line of the file is valid according to the POSIX standard. Also see No Newline at End of File for more information.
Swift source files should terminate with exactly 1 \n
character, not 0 nor more than 1.
Preferred
let myConstant = 42¬
<eof></eof>
Not Preferred
let myConstant = 42<eof></eof>
let myConstant = 42¬
¬
¬
<eof></eof>