Indentation Width

Indent code using either one tab or the configured amount of spaces, unindent to match previous indentations. Don’t indent the first line.

  • Identifier: indentation_width
  • Enabled by default: No
  • Supports autocorrection: No
  • Kind: style
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning
    indentation_width 4
    include_comments true
    include_compiler_directives true
    include_multiline_strings true
    include_multiline_conditions false

Non Triggering Examples

firstLine
secondLine
firstLine
    secondLine
firstLine
    secondLine
        thirdLine

        fourthLine
firstLine
    secondLine
        thirdLine
    //test
        fourthLine
firstLine
    secondLine
        thirdLine
fourthLine
guard let x = foo(),
      let y = bar() else {
    return
}
if let x = foo(),
   let y = bar() {
    doSomething()
}
while let x = foo(),
      let y = bar() {
    doSomething()
}
if let x = foo(),
   let y = bar(),
   let z = baz() {
    doSomething()
}

Triggering Examples

    firstLine
firstLine
        secondLine
firstLine
    secondLine

         fourthLine
firstLine
    secondLine
        thirdLine
 fourthLine