Identifier Name

Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared as static. Variable names should not be too long or too short.

  • Identifier: identifier_name
  • Enabled by default: Yes
  • Supports autocorrection: No
  • Kind: style
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    min_length
    KeyValue
    warning 3
    error 2
    max_length
    KeyValue
    warning 40
    error 60
    excluded [“^id$”]
    allowed_symbols []
    unallowed_symbols_severity error
    validates_start_with_lowercase error
    additional_operators [“!”, “%”, “&”, “*”, “+”, “-”, “.”, “/”, “<”, “=”, “>”, “?”, “^”, “|”, “~”]

Non Triggering Examples

let myLet = 0
var myVar = 0
private let _myLet = 0
private func _myFunc() {}
fileprivate let _myLet = 0
fileprivate func _myFunc() {}
fileprivate func _myFunc() {}
class Abc { static let MyLet = 0 }
let URL: NSURL? = nil
let XMLString: String? = nil
override var i = 0
enum Foo { case myEnum }
func isOperator(name: String) -> Bool
func typeForKind(_ kind: SwiftDeclarationKind) -> String
func == (lhs: SyntaxToken, rhs: SyntaxToken) -> Bool
override func IsOperator(name: String) -> Bool
enum Foo { case `private` }
enum Foo { case value(String) }
f { $abc in }
class Foo {
   static let Bar = 0
}
class Foo {
   static var Bar = 0
}
//
// additional_operators: ["!", "%", "&", "*", "+", "-", ".", "/", "<", "=", ">", "?", "^", "|", "~", "√"]
//

func  (arg: Double) -> Double { arg }

Triggering Examples

class C { static let _myLet = 0 }
class C { class let MyLet = 0 }
class C { static func MyFunc() {} }
class C { class func MyFunc() {} }
private let myLet_ = 0
let myExtremelyVeryVeryVeryVeryVeryVeryLongLet = 0
var myExtremelyVeryVeryVeryVeryVeryVeryLongVar = 0
private let _myExtremelyVeryVeryVeryVeryVeryVeryLongLet = 0
let i = 0
var aa = 0
private let _i = 0
if let _x {}
guard var x = x else {}
func myFunc(
    _ s: String,
    i j: Int,
    _ goodName: Double,
    name n: String,
    x: Int,
    abc: Double,
    _: Double,
    last _: Double
) {}
let (a, abc) = (1, 1)
if let i {}
for i in [] {}
f { x in }
f { $x in }
f { (x abc: Int, _ x: Int) in }
enum E {
    case c
    case case1(Int)
    case case2(a: Int)
    case case3(_ a: Int)
}
class C {
    var x: Int {
        get { 1 }
        set(y) { x = y }
    }
}
func ↓√ (arg: Double) -> Double { arg }