Comment Spacing

Prefer at least one space after slashes for comments

  • Identifier: comment_spacing
  • Enabled by default: Yes
  • Supports autocorrection: Yes
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

// This is a comment
/// Triple slash comment
// Multiline double-slash
// comment
/// Multiline triple-slash
/// comment
/// Multiline triple-slash
///   - This is indented
// - MARK: Mark comment
//: Swift Playground prose section
///////////////////////////////////////////////
// Comment with some lines of slashes boxing it
///////////////////////////////////////////////
//:#localized(key: "SwiftPlaygroundLocalizedProse")
/* Asterisk comment */
/*
    Multiline asterisk comment
*/
/*:
    Multiline Swift Playground prose section
*/
/*#-editable-code Swift Playground editable area*/default/*#-end-editable-code*/

Triggering Examples

//↓Something
//↓MARK
//↓👨‍👨‍👦‍👦Something
func a() {
    //↓This needs refactoring
    print("Something")
}
//↓We should improve above function
///↓This is a comment
/// Multiline triple-slash
///↓This line is incorrect, though
//↓- MARK: Mark comment
//:↓Swift Playground prose section