Skip to content

swift/swiftlint-analyze

Runs the SwiftLint analyzer rules over the compiler log of the build: unused imports and captured variables.

Part of the swift configuration, at the recommended level. It runs only when gspot check --only swift/swiftlint-analyze names it, once per scope. It runs swiftlint. It needs a build of the project. It runs on macOS.

An unused import slows the build and hides the real dependencies, and a captured variable can keep an object alive or read a stale value.

Remove what the rule names. List an import that the analyzer flags in error under tools.swiftlint.always_keep_imports.

An import that no compiled Swift source uses reports a finding. Remove the import.

Turn it off for some files, with a reason:

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

To silence one place, write a comment such as:

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