Skip to content

swift/swiftlint

Lints Swift files with the SwiftLint files of each scope and nested folder, and treats warnings as errors.

Part of the swift configuration, at the recommended level. It runs at the commit stage, per file. It runs swiftlint. gspot check --fix fixes what it can.

Forced casts and tries can crash, and a strong delegate can keep its owner alive.

Run gspot check --fix for the rules that fix themselves. Turn one rule off with gspot ignore swift/swiftlint --rule <id> --reason "<why>".

value as! NSString reports force_cast. Use as? and handle the failure, or change the input type so no cast remains.

Turn it off for some files, or one of its lint rules, with a reason:

gspot ignore swift/swiftlint --paths "<glob>" --reason "<why>"
gspot ignore swift/swiftlint --rule <rule> --reason "<why>"

To silence one place, write a comment such as:

// swiftlint:disable:next force_unwrapping - the URL is a literal