Swiftpack.co - Package - realm/SwiftLint


A tool to enforce Swift style and conventions, loosely based on GitHub's Swift Style Guide.

SwiftLint hooks into Clang and SourceKit to use the AST representation of your source files for more accurate results.

Build Status codecov.io

This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to info@realm.io.

Language Switch: 中文, 한국어.


Using Homebrew:

brew install swiftlint

Using CocoaPods:

Simply add the following line to your Podfile:

pod 'SwiftLint'

This will download the SwiftLint binaries and dependencies in Pods/ during your next pod install execution and will allow you to invoke it via ${PODS_ROOT}/SwiftLint/swiftlint in your Script Build Phases.

This is the recommended way to install a specific version of SwiftLint since it supports installing a pinned version rather than simply the latest (which is the case with Homebrew).

Note that this will add the SwiftLint binaries, its dependencies' binaries and the Swift binary library distribution to the Pods/ directory, so checking in this directory to SCM such as git is discouraged.

Using Mint:

$ mint install realm/SwiftLint

Using a pre-built package:

You can also install SwiftLint by downloading SwiftLint.pkg from the latest GitHub release and running it.

Installing from source:

You can also build and install from source by cloning this project and running make install (Xcode 11.4 or later).

Known Installation Issues On MacOS Before 10.14.4

Starting with SwiftLint 0.32.0, if you get an error similar to dyld: Symbol not found: _$s11SubSequenceSlTl when running SwiftLint, you'll need to install the Swift 5 Runtime Support for Command Line Tools.

Alternatively, you can:

  • Update to macOS 10.14.4 or later
  • Install Xcode 11.4 or later at /Applications/Xcode.app
  • Rebuild SwiftLint from source using Xcode 11.4 or later



To get a high-level overview of recommended ways to integrate SwiftLint into your project, we encourage you to watch this presentation or read the transcript:



Integrate SwiftLint into your Xcode project to get warnings and errors displayed in the issue navigator.

To do this click the Project in the file navigator, then click the primary app target, and go to Build Phases. Click the + and select "New Run Script Phase". Insert the following as the script:

if which swiftlint >/dev/null; then
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"

You might want to move your SwiftLint phase directly before 'Compile Sources' step, to detect errors quickly before compiling. However, SwiftLint is designed to run on valid Swift code that cleanly completes the compiler's parsing stage. So running SwiftLint before 'Compile Sources' might yield some incorrect results.

If you wish to autocorrect violations as well, your script could run swiftlint autocorrect && swiftlint instead of just swiftlint. This will mean that all correctable violations are fixed, while ensuring warnings show up in your project for remaining violations.

If you've installed SwiftLint via CocoaPods the script should look like this:


Format on Save Xcode Plugin

To run swiftlint autocorrect on save in Xcode, install the SwiftLintXcode plugin from Alcatraz.

⚠️This plugin will not work with Xcode 8 or later without disabling SIP. This is not recommended.


To integrate SwiftLint with AppCode, install this plugin and configure SwiftLint's installed path in the plugin's preferences. The autocorrect action is available via ⌥⏎.


To integrate SwiftLint with Atom, install the linter-swiftlint package from APM.


You can use the official swiftlint fastlane action to run SwiftLint as part of your fastlane process.

    mode: :lint,                            # SwiftLint mode: :lint (default) or :autocorrect
    executable: "Pods/SwiftLint/swiftlint", # The SwiftLint binary path (optional). Important if you've installed it via CocoaPods
    path: "/path/to/lint",                  # Specify path to lint (optional)
    output_file: "swiftlint.result.json",   # The path of the output file (optional)
    reporter: "json",                       # The custom reporter to use (optional)
    config_file: ".swiftlint-ci.yml",       # The path of the configuration file (optional)
    files: [                                # List of files to process (optional)
    ignore_exit_status: true,               # Allow fastlane to continue even if SwiftLint returns a non-zero exit status (Default: false)
    quiet: true,                            # Don't print status logs like 'Linting ' & 'Done linting' (Default: false)
    strict: true                            # Fail on warnings? (Default: false)

Command Line

$ swiftlint help
Available commands:

   analyze         [Experimental] Run analysis rules
   autocorrect     Automatically correct warnings and errors
   generate-docs   Generates markdown documentation for all rules
   help            Display general or command-specific help
   lint            Print lint warnings and errors (default command)
   rules           Display the list of rules and their identifiers
   version         Display the current version of SwiftLint

Run swiftlint in the directory containing the Swift files to lint. Directories will be searched recursively.

To specify a list of files when using lint, autocorrect or analyze (like the list of files modified by Xcode specified by the ExtraBuildPhase Xcode plugin, or modified files in the working tree based on git ls-files -m), you can do so by passing the option --use-script-input-files and setting the following instance variables: SCRIPT_INPUT_FILE_COUNT and SCRIPT_INPUT_FILE_0, SCRIPT_INPUT_FILE_1...SCRIPT_INPUT_FILE_{SCRIPT_INPUT_FILE_COUNT}.

These are same environment variables set for input files to custom Xcode script phases.

Working With Multiple Swift Versions

SwiftLint hooks into SourceKit so it continues working even as Swift evolves!

This also keeps SwiftLint lean, as it doesn't need to ship with a full Swift compiler, it just communicates with the official one you already have installed on your machine.

You should always run SwiftLint with the same toolchain you use to compile your code.

You may want to override SwiftLint's default Swift toolchain if you have multiple toolchains or Xcodes installed.

Here's the order in which SwiftLint determines which Swift toolchain to use:

  • xcrun -find swift
  • /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
  • /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
  • ~/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
  • ~/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain

sourcekitd.framework is expected to be found in the usr/lib/ subdirectory of the value passed in the paths above.

You may also set the TOOLCHAINS environment variable to the reverse-DNS notation that identifies a Swift toolchain version:

$ TOOLCHAINS=com.apple.dt.toolchain.Swift_2_3 swiftlint autocorrect

On Linux, SourceKit is expected to be located in /usr/lib/libsourcekitdInProc.so or specified by the LINUX_SOURCEKIT_LIB_PATH environment variable.

Swift Version Support

Here's a reference of which SwiftLint version to use for a given Swift version.

Swift version Last supported SwiftLint release
Swift 1.x SwiftLint 0.1.2
Swift 2.x SwiftLint 0.18.1
Swift 3.x SwiftLint 0.25.1
Swift 4.0-4.1.x SwiftLint 0.28.2
Swift 4.2.x SwiftLint 0.35.0
Swift 5.x Latest


Over 100 rules are included in SwiftLint and the Swift community (that's you!) continues to contribute more over time. Pull requests are encouraged.

You can find an updated list of rules and more information about them here.

You can also check Source/SwiftLintFramework/Rules directory to see their implementation.

Opt-In Rules

opt_in_rules are disabled by default (i.e., you have to explicitly enable them in your configuration file).

Guidelines on when to mark a rule as opt-in:

  • A rule that can have many false positives (e.g. empty_count)
  • A rule that is too slow
  • A rule that is not general consensus or is only useful in some cases (e.g. force_unwrapping)

Disable rules in code

Rules can be disabled with a comment inside a source file with the following format:

// swiftlint:disable <rule1> [<rule2> <rule3>...]

The rules will be disabled until the end of the file or until the linter sees a matching enable comment:

// swiftlint:enable <rule1> [<rule2> <rule3>...]

For example:

// swiftlint:disable colon
let noWarning :String = "" // No warning about colons immediately after variable names!
// swiftlint:enable colon
let hasWarning :String = "" // Warning generated about colons immediately after variable names

Including the all keyword will disable all rules until the linter sees a matching enable comment:

// swiftlint:disable all // swiftlint:enable all

For example:

// swiftlint:disable all
let noWarning :String = "" // No warning about colons immediately after variable names!
let i = "" // Also no warning about short identifier names
// swiftlint:enable all
let hasWarning :String = "" // Warning generated about colons immediately after variable names
let y = "" // Warning generated about short identifier names

It's also possible to modify a disable or enable command by appending :previous, :this or :next for only applying the command to the previous, this (current) or next line respectively.

For example:

// swiftlint:disable:next force_cast
let noWarning = NSNumber() as! Int
let hasWarning = NSNumber() as! Int
let noWarning2 = NSNumber() as! Int // swiftlint:disable:this force_cast
let noWarning3 = NSNumber() as! Int
// swiftlint:disable:previous force_cast

Run swiftlint rules to print a list of all available rules and their identifiers.


Configure SwiftLint by adding a .swiftlint.yml file from the directory you'll run SwiftLint from. The following parameters can be configured:

Rule inclusion:

  • disabled_rules: Disable rules from the default enabled set.
  • opt_in_rules: Enable rules not from the default set.
  • only_rules: Only the rules specified in this list will be enabled. Cannot be specified alongside disabled_rules or opt_in_rules.
  • analyzer_rules: This is an entirely separate list of rules that are only run by the analyze command. All analyzer rules are opt-in, so this is the only configurable rule list, there are no equivalents for disabled_rules only_rules.
# By default, SwiftLint uses a set of sensible default rules you can adjust:
disabled_rules: # rule identifiers turned on by default to exclude from running
  - colon
  - comma
  - control_statement
opt_in_rules: # some rules are turned off by default, so you need to opt-in
  - empty_count # Find all the available rules by running: `swiftlint rules`

# Alternatively, specify all rules explicitly by uncommenting this option:
# only_rules: # delete `disabled_rules` & `opt_in_rules` if using this
#   - empty_parameters
#   - vertical_whitespace

included: # paths to include during linting. `--path` is ignored if present.
  - Source
excluded: # paths to ignore during linting. Takes precedence over `included`.
  - Carthage
  - Pods
  - Source/ExcludedFolder
  - Source/ExcludedFile.swift
  - Source/*/ExcludedFile.swift # Exclude files with a wildcard
analyzer_rules: # Rules run by `swiftlint analyze` (experimental)
  - explicit_self

# configurable rules can be customized from this configuration file
# binary rules can set their severity level
force_cast: warning # implicitly
  severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 110
# they can set both implicitly with an array
  - 300 # warning
  - 400 # error
# or they can set both explicitly
  warning: 500
  error: 1200
# naming rules can set warnings/errors for min_length and max_length
# additionally they can set excluded names
  min_length: 4 # only warning
  max_length: # warning and error
    warning: 40
    error: 50
  excluded: iPhone # excluded via string
  allowed_symbols: ["_"] # these are allowed in type names
  min_length: # only min_length
    error: 4 # only error
  excluded: # excluded via string array
    - id
    - URL
    - GlobalAPIKey
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, codeclimate, junit, html, emoji, sonarqube, markdown, github-actions-logging)

You can also use environment variables in your configuration file, by using ${SOME_VARIABLE} in a string.

Defining Custom Rules

You can define custom regex-based rules in your configuration file using the following syntax:

  pirates_beat_ninjas: # rule identifier
    included: ".*\\.swift" # regex that defines paths to include during linting. optional.
    excluded: ".*Test\\.swift" # regex that defines paths to exclude during linting. optional
    name: "Pirates Beat Ninjas" # rule name. optional.
    regex: "([nN]inja)" # matching pattern
    capture_group: 0 # number of regex capture group to highlight the rule violation at. optional.
    match_kinds: # SyntaxKinds to match. optional.
      - comment
      - identifier
    message: "Pirates are better than ninjas." # violation message. optional.
    severity: error # violation severity. optional.
    regex: "([nN]inja)"
    match_kinds: string

This is what the output would look like:

You can filter the matches by providing one or more match_kinds, which will reject matches that include syntax kinds that are not present in this list. Here are all the possible syntax kinds:

  • argument
  • attribute.builtin
  • attribute.id
  • buildconfig.id
  • buildconfig.keyword
  • comment
  • comment.mark
  • comment.url
  • doccomment
  • doccomment.field
  • identifier
  • keyword
  • number
  • objectliteral
  • parameter
  • placeholder
  • string
  • string_interpolation_anchor
  • typeidentifier

If using custom rules in combination with only_rules, make sure to add custom_rules as an item under only_rules.


SwiftLint can automatically correct certain violations. Files on disk are overwritten with a corrected version.

Please make sure to have backups of these files before running swiftlint autocorrect, otherwise important data may be lost.

Standard linting is disabled while correcting because of the high likelihood of violations (or their offsets) being incorrect after modifying a file while applying corrections.

Analyze (experimental)

The experimental swiftlint analyze command can lint Swift files using the full type-checked AST. The compiler log path containing the clean swiftc build command invocation (incremental builds will fail) must be passed to analyze via the --compiler-log-path flag. e.g. --compiler-log-path /path/to/xcodebuild.log

This can be obtained by running xcodebuild -workspace {WORKSPACE}.xcworkspace -scheme {SCHEME} > xcodebuild.log with a clean DerivedData folder.

This command and related code in SwiftLint is subject to substantial changes at any time while this feature is marked as experimental. Analyzer rules also tend to be considerably slower than lint rules.

Using Multiple Configuration Files

SwiftLint offers a variety of ways to include multiple configuration files. Multiple configuration files get merged into one single configuration that is then applied just as a single configuration file would get applied.

There are quite a lot of use cases where using multiple configuration files could be helpful:

For instance, one could use a team-wide shared SwiftLint configuration while allowing overrrides in each project via a child configuration file.

Team-Wide Configuration:

- force_cast

Project-Specific Configuration:

- force_cast

Child / Parent Configs (Locally)

You can specify a child_config and / or a parent_config reference within a configuration file. These references should be local paths relative to the folder of the configuration file they are specified in. This even works recursively, as long as there are no cycles and no ambiguities.

A child config is treated as a refinement and therefore has a higher priority, while a parent config is considered a base with lower priority in case of conflicts.

Here's an example, assuming you have the following file structure:

    |_ .swiftlint.yml
    |_ .swiftlint_refinement.yml
    |_ Base
        |_ .swiftlint_base.yml

To include both the refinement and the base file, your .swiftlint.yml should look like this:

child_config: .swiftlint_refinement.yml
parent_config: Base/.swiftlint_base.yml

When merging parent and child configs, included and excluded configurations are processed carefully to account for differences in the directory location of the containing configuration files.

Child / Parent Configs (Remote)

Just as you can provide local child_config / parent_config references, instead of referencing local paths, you can just put urls that lead to configuration files. In order for SwiftLint to detect these remote references, they must start with http:// or https://.

The referenced remote configuration files may even recursively reference other remote configuration files, but aren't allowed to include local references.

Using a remote reference, your .swiftlint.yml could look like this:

parent_config: https://myteamserver.com/our-base-swiftlint-config.yml

Every time you run SwiftLint and have an Internet connection, SwiftLint tries to get a new version of every remote configuration that is referenced. If this request times out, a cached version is used if available. If there is no cached version available, SwiftLint fails – but no worries, a cached version should be there once SwiftLint has run successfully at least once.

If needed, the timeouts for the remote configuration fetching can be specified manually via the configuration file(s) using the remote_timeout / remote_timeout_if_cached specifiers. These values default to 2 / 1 second(s).

Command Line

Instead of just providing one configuration file when running SwiftLint via the command line, you can also pass a hierarchy, where the first configuration is treated as a parent, while the last one is treated as the highest-priority child.

A simple example including just two configuration files looks like this:

swiftlint --config ".swiftlint.yml .swiftlint_child.yml"

Nested Configurations

In addition to a main configuration (the .swiftlint.yml file in the root folder), you can put other configuration files named .swiftlint.yml into the directory structure that then get merged as a child config, but only with an effect for those files that are within the same directory as the config or in a deeper directory where there isn't another configuration file. In other words: Nested configurations don't work recursively – there's a maximum number of one nested configuration per file that may be applied in addition to the main configuration.

.swiftlint.yml files are only considered as a nested configuration if they have not been used to build the main configuration already (e. g. by having been referenced via something like child_config: Folder/.swiftlint.yml). Also, parent_config / child_config specifications of nested configurations are getting ignored because there's no sense to that.

If one (or more) SwiftLint file(s) are explicitly specified via the --config parameter, that configuration will be treated as an override, no matter whether there exist other .swiftlint.yml files somewhere within the directory. So if you want to use use nested configurations, you can't use the -- config parameter.


MIT licensed.


SwiftLint is maintained and funded by Realm Inc. The names and logos for Realm are trademarks of Realm Inc.

We :heart: open source software! See our other open source projects, read our blog, or say hi on twitter (@realm).

Our thanks to MacStadium for providing a Mac Mini to run our performance tests.


Stars: 14107

Used By

Total: 0


0.41.0: World’s Cleanest Voting Booth -

laundromat voting


  • Changed behavior of strict option on lint and analyze to treat all warnings as errors instead of only changing the exit code.
    Jeehut #3312

  • Removed the unneeded_notification_center_removal rule because it was based on an incorrect premise.
    JP Simard #3338

  • The whitelist_rules configuration key has been renamed to only_rules.
    Dalton Claybrook


  • None.


  • Add use-alternative-excluding option to speed up linting in cases described in #3325. This option yields different exclusion behavior.
    JohnReeze #3304

  • Add test_case_accessibility rule.
    Keith Smiley #3376

  • Add more details to CONTRIBUTING.md.
    mknabbe #1280

  • Remove @IBOutlet and @IBInspectable from UnusedDeclarationRule.
    Keith Smiley #3184

  • Add allow_multiline_func configuration option to opening_brace rule, to allow placing { on new line in case of multiline function. Defaults to false.
    Zsolt Kovács #1921

  • Update the nslocalizedstring_key rule to validate the comment argument in addition to the key argument.
    Dalton Claybrook #3334

  • Add inclusive_language rule to encourage the use of inclusive language that avoids discrimination against groups of people.
    Dalton Claybrook

  • Add prefer_nimble opt-in rule to encourage using Nimble matchers over the XCTest ones.
    Marcelo Fabri #3293

  • unused_closure_parameter rule now validates closures outside of function calls.
    Marcelo Fabri #1082

  • Improve documentation for running SwiftLint as Xcode build phase.
    Christian Mitteldorf #3169

  • Add skip_aligned_constants (defaults to true) and lines_look_around (defaults to 2) configuration parameters to the operator_usage_whitespace rule.
    Paul Taykalo #3388

Bug Fixes

  • Fix parsing of Xcode 12 compiler logs for analyzer rules.
    JP Simard #3365

  • Fix some SwiftUI unused declaration rule false positives.
    JP Simard #3365

  • Fix some false positives in rule explicit_self.
    Sven Münnich

  • Fix incorrect autocorrection in prefer_zero_over_explicit_init rule.
    Paul Taykalo

  • Rule unused_capture_list should not be triggered by unowned self keyword.
    hank121314 #3389

  • Fix severity configuration for indentation_width.
    Samasaur1 #3346

  • Fix DuplicateImportsRule's support for import attributes.
    Keith Smiley #3402

  • Allow "allowed symbols" as first character in identifier_name.
    JP Simard #3306

  • Fix false positives with parameterized attributes in attributes.
    JP Simard #3316

  • Fix some missed cases in rule unavailable_function.
    Quinn Taylor #3374

  • Fix incorrect violation message for line length violations.
    JP Simard #3333

  • Fix inconsistency in operator_usage_whitespace rule.
    Paul Taykalo #3321

  • Fix false positives in convenience_type rule for types that cannot be converted to enums.
    ZevEisenberg #3033

  • Fix finding a nested config when a single file path is passed.
    Seth Friedman

  • Fix incorrect calculation of the root path when a directory in the tree is passed in as a path argument.
    Seth Friedman #3383

  • Fix rare false positive in toggle_bool rule.
    Marcelo Fabri #3398

0.40.3: Greased Up Drum Bearings -


  • None.


  • None.


  • Make the unused_declaration rule run 3-5 times faster, and enable it to detect more occurrences of unused declarations.
    JP Simard

  • Remove unneeded internal locking overhead, leading to increased performance in multithreaded operations.
    JP Simard

  • Skip correcting file if the swift parser reports a warning or an error.
    JP Simard #3343

Bug Fixes

  • Rule unused_capture_list should not be triggered by self keyword.
    hank121314 #2367

  • Rule multiple_closures_with_trailing_closure no longer triggers when Swift 5.3's 'multiple trailing closures' feature is used. Jumhyn #3295

0.40.2: Demo Unit -


  • None.


  • None.


  • Improve description for empty_enum_arguments.
    Lukas Schmidt

  • Add support for excluded_match_kinds custom rule config parameter.
    Ryan Demo

Bug Fixes

  • None.

0.40.1: A Baffling Response -


  • None.


  • None.


  • Add support for params files for file paths.

Bug Fixes

  • Fix .swift-version to use Swift 5.1.
    cfiken #3297

  • Fix test testDetectSwiftVersion for Swift 5.2.5.
    cfiken #3299

0.40.0: Washable Mask -


  • SwiftLint now requires Swift 5.1 or higher to build.
    JP Simard

  • Improve compile commands json file validation. If you previously provided invalid files or arguments, the command will now abort.
    Keith Smiley


  • None.


  • JUnit reporter for GitLab artifact:report:junit with better representation of found issues.
    krin-san #3177

  • Add opt-in ibinspectable_in_extension rule to lint against @IBInspectable properties in extensions.
    Keith Smiley

  • Add computed_accessors_order rule to validate the order of get and set accessors in computed properties and subscripts.
    Marcelo Fabri #3158

  • Extend empty_enum_arguments rule to support if case and guard case.
    Zsolt Kovács #3103

  • Add prefer_zero_over_explicit_init opt-in rule to enforce using .zero instead of calling constructor with zero arguments (e.g. CGPoint(x: 0, y: 0)) when using CoreGraphics types.
    Anton Nazarov #3190

  • Add swiftlint docs command to easily open online documentation.

  • Add unneeded_notification_center_removal rule to warn against using NotificationCenter.removeObserver(self) in deinit since it's not required after iOS 9/macOS 10.11.
    Amzd #2755

Bug Fixes

  • Fix UnusedImportRule breaking transitive imports.

  • Fix severity level configuration for duplicate_imports.
    Yusuke Goto

  • Fixes false positives for multiline_parameters_brackets and multiline_arguments_brackets.
    Noah Gilmore #3167

  • Fix conflict of 'opening_brace' with 'implicit_return' for functions implicitly returning a closure.
    SimplyDanny #3034

  • Fix false positive on switch_case_on_newline rule with do/catch statements when using Swift 5.3.
    Marcelo Fabri #3253

  • Fix false positive uppercase enum case in raw_value_for_camel_cased_codable_enum rule.

  • Fix false positive in no_space_in_method_call rule with multiple trailing closures (Swift 5.3).
    Marcelo Fabri #3259

  • Fix false negative in explicit_acl rule when using extension with Swift 5.2+.
    Marcelo Fabri #3186

  • closure_parameter_position now triggers in closures that are not inside a function call and also validates captured variables.
    Marcelo Fabri #3225

  • Fix some cases where the output would be incomplete when running SwiftLint on Linux.
    Marcelo Fabri #3214

  • compiler_protocol_init now triggers on IndexSet(arrayLiteral:).
    Janak Shah #3284

  • Fix false positives in extension_access_modifier rule when using Swift 5.2.
    Marcelo Fabri #3150

0.39.2: Stay Home -

This is the last release to support building with Swift 5.0.x.


  • None.


  • None.


  • Add configuration options to the unused_import rule to require explicit import statements for each module referenced in a source file (require_explicit_imports). When this setting is enabled, an allowed_transitive_imports setting may also be specified to allow a mapping of modules to transitively imported modules. See PR for details: https://github.com/realm/SwiftLint/pull/3123
    JP Simard #3116

Bug Fixes

  • Fix more false positives in implicit_getter rule in extensions when using Swift 5.2.
    Marcelo Fabri #3149

  • Fix false positives in redundant_objc_attribute rule in extensions when using Swift 5.2.
    Marcelo Fabri

  • Fix false positives in attributes rule when using rethrows using Swift 5.2.
    JP Simard

  • Fix false positives in valid_ibinspectable rule when defining inspectable properties in class extensions with computed properties using Swift 5.2.
    JP Simard

0.39.1: The Laundromat has a Rotating Door -


  • The new rules introduced in 0.39.0 that depend on SwiftSyntax have been temporarily removed as we work out release packaging issues.
    • prohibited_nan_comparison
    • return_value_from_void_function
    • tuple_pattern
    • void_function_in_ternary
      JP Simard #3105


  • None.


  • None.

Bug Fixes

  • Fix unused_import rule reported locations and corrections when multiple @testable imports are involved.
    JP Simard

0.39.0: A Visitor in the Laundromat -


  • Replace all uses of Int/Int64/NSRange representing byte offsets to use newly introduced ByteCount and ByteRange values instead. This will minimize the risk of accidentally using a byte-based offset in character-based contexts.
    Paul Taykalo JP Simard

  • SwiftLint now imports SwiftSyntax and requires Xcode 11.0 to build.
    Marcelo Fabri


  • None.


  • Add option to pass successfully if no files passed to SwiftLint are lintable.
    thedavidharris #2608i

  • Add deinitializer type content to type_contents_order rule instead of grouping it with initializers.
    Steven Magdy

  • Inline test failure messages to make development of SwiftLint easier. Test failures in triggering and non-triggering examples will appear inline in their respective files so you can immediately see which cases are working and which are not.
    ZevEisenberg #3040

  • Introduce a new SyntaxRule that enables writing rules using SwiftSyntax.
    Marcelo Fabri

  • Add tuple_pattern opt-in rule to warn against using assigning variables through a tuple pattern when the left side of the assignment contains labels.
    Marcelo Fabri #2203

  • Add return_value_from_void_function opt-in rule to warn against using return <expression> in a function that is Void.
    Marcelo Fabri

  • Add void_function_in_ternary opt-in rule to warn against using a ternary operator to call Void functions.
    Marcelo Fabri #2358

  • Add only_after_dot configuration option to empty_count rule. With the option enabled, empty_count rule will ignore variables named count. By default, this option is disabled.
    Zsolt Kovács #827

  • Add prohibited_nan_comparison opt-in rule to validate using isNaN instead of comparing values to the .nan constant.
    Marcelo Fabri #2086

Bug Fixes

  • Fix discarded_notification_center_observer false positives when capturing observers into an array.
    Petteri Huusko

  • Fix crash when non-closed #if was present in file.

  • Fix false positives when line ends with carriage return + line feed.
    John Mueller #3060

  • Implicit_return description now reports current config correctly. John Buckley

  • Fix false positive in implicit_getter rule in extensions when using Swift 5.2.
    Marcelo Fabri #3074

  • Do not trigger optional_enum_case_matching rule on _? as the ? might be required in some situations.
    Marcelo Fabri #3057

  • Fix false positive in attributes rule with @escaping parameters when using Swift 5.2.
    Marcelo Fabri #3079

  • Fix false positive in empty_string rule when using multiline string literals.
    Marcelo Fabri #3100

0.38.2: Machine Repair Manual -


  • None.


  • None.


  • Add option to configure which kinds of expressions should omit their return keyword by introducing an included configuration for the implicit_return rule. Supported values are closure, function and getter. Defaults to all three.
    Sven Münnich #2870

  • Add --correctable and --verbose arguments to the rules command to allow displaying only correctable rules, and to always print the full configuration details regardless of your terminal width.
    Optional Endeavors

  • Add capture_group option to custom_rules for more fine-grained placement of the location marker for violating code.

  • Add orphaned_doc_comment rule to catch doc comments that are not attached to any declarations.
    Marcelo Fabri #2989

  • Add new indentation opt-in rule (indentation_width) checking for super-basic additive indentation pattern.
    Frederick Pietschmann #227

  • Catch previously missed violations in the optional_enum_case_matching rule when case expressions involved tuples.
    JP Simard

  • API docs for SwiftLintFramework are now available at realm.github.io/SwiftLint. Rules.md now redirects to the rules directory in the API docs here. Contributors no longer need to update rule documentation in PRs as this is now done automatically. The rule documentation now includes the default configuration.
    JP Simard #1653 #1704 #2808 #2933 #2961

Bug Fixes

  • Fix issues in unused_import rule when correcting violations in files containing @testable imports where more than the unused imports would be removed.
    JP Simard

0.38.1: Extra Shiny Pulsator Cap -


  • None.


  • None.


  • Make weak_delegate rule correctable.

  • Allow SubstitutionCorrectableRule to return nil instead of a correction to indicate that a suitable correction couldn't be found for a specific case.

  • Add enum_case_associated_value_count opt-in rule.
    lakpa #2997

  • Add optional_enum_case_matching opt-in rule to validate that optional enum cases are matched without using ? when using Swift 5.1 or above. See SR-7799 for more details.
    Marcelo Fabri

  • Add prefer_self_type_over_type_of_self opt-in rule to enforce using Self instead of type(of: self) when using Swift 5.1 or above.
    Marcelo Fabri #3003

Bug Fixes

  • Fix crash in unused_import rule when unused imports have trailing comments.
    JP Simard #2990

  • Handle @_exported imports in unused_import rule.
    JP Simard #2877

  • Fix false positives from the unused_declaration rule involving functions in protocol extensions.
    JP Simard

  • Fix parsing of SwiftLint commands containing a URL in their trailing comment.
    Sven Münnich

  • Added missing parameters to FileNameConfiguration.consoleDescription.
    timcmiller #3009

  • Fix crash when SourceKit returns out of bounds string byte offsets.
    JP Simard

0.38.0: Toroidal Agitation -


  • Replace the SyntaxToken and SyntaxMap structures used in public SwiftLintFramework APIs with a new SwiftLintSyntaxToken and SwiftlintSyntaxMap wrappers over structures returned from SourceKitten.
    PaulTaykalo #2955


  • None.


  • Make control_statement rule correctable.

  • Add expiring_todo opt-in rule to allow developers to mark their todos with an expiration date.
    Dan Loman #727

  • Support compilation databases for swiftlint analayze.
    kastiglione #2962

Bug Fixes

0.37.0: Double Load -


  • Replace the [String: SourceKittenRepresentable] dictionaries used in public SwiftLintFramework APIs with a new SourceKittenDictionary wrapper over dictionaries returned from SourceKitten.
    PaulTaykalo #2922

  • Update Commandant dependency to version 0.17.0, removing the antitypical/Result dependency in favor of the Swift standard library's Result type.
    JP Simard


  • None.


  • Speed up many operations by using SwiftLintFile wrapper over File from SourceKitten, caching most members derived from the File.
    PaulTaykalo #2929

  • Speed up Swiftlint by using swift enums instead of raw values for dictionary lookups.
    PaulTaykalo #2924

  • Speed up Identical Operands rule by using syntaxmap instead of regular expressions.
    PaulTaykalo #2918

  • Speed up syntax token lookups, which can improve performance when linting large files.

  • Use faster comparison in 'file_types_order' rule.
    PaulTaykalo #2949

  • Speed up recursively executed rules (all AST rules and some others) by avoiding the creation of many intermediate collections when accumulating results.
    PaulTaykalo #2951

  • Add GitHub Actions Logging reporter (github-actions-logging).
    Norio Nomura

Bug Fixes

  • None.

0.36.0: 👕👚👗 -


  • SwiftLint now requires Swift 5.0 or higher to build.
    JP Simard


  • None.


  • Add contains_over_range_nil_comparison opt-in rule to prefer using contains over comparison of range(of:) to nil.
    Colton Schlosser #2776

  • Make contains_over_first_not_nil rule also match first(where:) == nil.
    Colton Schlosser

  • Add two new cases to the Mark rule to detect a Mark using three slashes.
    nvanfleet #2866

  • Add flatmap_over_map_reduce opt-in rule to prefer using flatMap over map { ... }.reduce([], +).
    Marcelo Fabri #2883

  • Add autocorrection to syntactic_sugar.
    Ivan Vavilov

  • Make toggle_bool rule substitution correctable.

  • Optimize the performance of redundant_void_return rule.
    Marcelo Fabri

  • Support building with Swift 5.1 on Linux.
    Marcelo Fabri #2874

  • Add raw_value_for_camel_cased_codable_enum opt-in rule to enforce raw values for camel cased Codable String enum cases.
    Marko Pejovic #2888

  • Speedup LetVarWhiteSpacesRule.
    PaulTaykalo #2901

Bug Fixes

  • Fix running analyzer rules on the output of builds performed with Xcode 11 or later.
    JP Simard

0.35.0: Secondary Lint Trap -

This is the last release to support building with Swift 4.2.x.


  • None.


  • None.


  • Type name rules considers SwiftUI template code.
    atfelix #2791

  • Add no_space_in_method_call rule to validate that there're no spaces between the method name and parentheses in a method call.
    Marcelo Fabri

  • Add contains_over_filter_count opt-in rule to warn against using expressions like filter(where:).count > 0 instead of contains(where:).
    Marcelo Fabri #2803

  • Add contains_over_filter_is_empty opt-in rule to warn against using expressions like filter(where:).isEmpty instead of contains(where:).
    Marcelo Fabri

  • Add empty_collection_literal opt-in rule to prefer using isEmpty to comparison to [] or [:].
    Colton Schlosser #2807

Bug Fixes

0.34.0: Anti-Static Wool Dryer Balls -


  • To enable collecting rules, many breaking changes to SwiftLintFramework's public API were made the Linter type was significantely changed, and a new CollectedLinter type was introduced. Many public SwiftLintFramework APIs that interacted with Linter have also been affected. More new types and protocols were added such as RuleStorage, AnyCollectingRule, CollectingRule, CollectingCorrectableRule. We are not aware of any significant users of the SwiftLintFramework library, so if you are affected by this, please reach out to SwiftLint contributors by filing a GitHub issue about your use case.
    Elliott Williams JP Simard


  • Add a two-stage CollectingRule protocol to support rules that collect data from all files before validating. Collecting rules implement a collect method which is called once for every file, before any file is checked for violations. By collecting, rules can be written which validate across multiple files for things like unused declarations.
    Elliott Williams #2431

  • Add a new unused_declaration analyzer rule to lint for unused declarations. By default, detects unused fileprivate, private and internal declarations. Configure the rule with include_public_and_open: true to also detect unused public and open declarations.
    JP Simard

  • Completely remove the unused_private_declaration rule. Please use unused_declaration instead.
    JP Simard


  • None.

Bug Fixes

  • None.

0.33.1: Coin-Operated Property Wrapper -


  • None.


  • None.


  • Significantly improve performance when running with a large number of cached configurations or when running with many cached results. This was done by splitting each configuration to have its own cache and by encoding the cache as a binary property list instead of json.
    Colton Schlosser JP Simard

  • Several public types in SwiftLintFramework have added Codable conformance: Location, RuleDescription, RuleKind, StyleViolation, SwiftVersion, ViolationSeverity.
    JP Simard

  • Print full relative path to file in log output when it matches the file name of another path being linted.
    Keith Smiley

Bug Fixes

  • Don't trigger vertical_parameter_alignment violations when using parameters with attributes such as @ViewBuilder in function declarations.
    Marcelo Fabri #2792

  • Fix false positive in function_default_parameter_at_end rule when using a closure parameter with default value.
    Marcelo Fabri #2788

0.33.0: Worldwide Dryers Conference -


  • Remove the weak_computed_property rule. Please see linked issue for discussion and rationale.
    JP Simard #2712


  • None.


  • Add " - " delimiter to allow commenting SwiftLint commands without triggering superfluous_disable_command.
    Kevin Randrup

  • Make testSimulateHomebrewTest() test opt-in because it may fail on unknown condition. Set SWIFTLINT_FRAMEWORK_TEST_ENABLE_SIMULATE_HOMEBREW_TEST environment variable to test like:

    swift test --filter testSimulateHomebrewTest

    Norio Nomura

  • Add option to configure how nested types should be separated in file names by introducting nested_type_separator configuration for the file_name rule.
    Frederick Pietschmann #2717

  • Add unowned_variable_capture opt-in rule to warn against unowned captures in closures when using Swift 5.
    Marcelo Fabri #2097

  • Don't trigger a no_fallthrough_only violation if next case is an @unknown default.
    Marcelo Fabri #2696

  • Add duplicate_enum_cases rule to validate that an enum doesn't contain duplicated cases, as it's impossible to switch on it (see SR-10077 for details).
    Marcelo Fabri #2676

  • Add legacy_multiple opt-in rule to warn against using the remainder operator (%) checking for a remainder of zero when using Swift 5.
    Marcelo Fabri #2612

Bug Fixes

  • Don't trigger redundant_void_return violations when using subscript as the return type is required.
    Marcelo Fabri

  • Skip module import if cursor info is missing module info.
    alvarhansen #2746

  • Don't trigger file_types_order violations in files only containing extensions.
    Sam Rayner #2749

  • Force-unwrapping self should trigger a violation of the force_unwrapping rule.
    Dalton Claybrook #2759

0.32.0: Wash-N-Fold-N-Reduce -

This release has improved support for building and running SwiftLint using Swift 5, adds seven new (super useful) rules and fixes a number of false positives or missing violations.


  • None.


  • None.


  • Add reduce_boolean rule to prefer simpler constructs over reduce(Boolean).
    Xavier Lowmiller #2675

  • Add nsobject_prefer_isequal rule to warn against implementing == on an NSObject subclass as calling isEqual (i.e. when using the class from Objective-C) will not use the defined == method.
    Matthew Healy #2663

  • Add reduce_into opt-in rule to encourage the use of reduce(into:_:) instead of reduce(_:_:) which is less performant.
    Dalton Claybrook #2658

  • Remove @ mark to fix invalid link in Rules.md.
    Hiroki Nagasawa #2669

  • Add new opt-in rule file_types_order to specify how the types in a file should be sorted.
    Cihat Gündüz #2294

  • Add new opt-in rule type_contents_order to specify the order of subtypes, properties, methods & more within a type.
    Cihat Gündüz #2294

  • Add nslocalizedstring_require_bundle rule to ensure calls to NSLocalizedString specify the bundle where the strings file is located.
    Matthew Healy #2595

  • contains_over_first_not_nil rule now also checks for firstIndex(where:).
    Marcelo Fabri #2678

  • Add unused_capture_list rule to ensure that all references in a closure capture list are used.
    Dalton Claybrook #2715

  • SwiftLint can now be compiled using Xcode 10.2.
    Marcelo Fabri Norio Nomura #2693

Bug Fixes

  • Fix bug where SwiftLint ignores excluded files list in a nested configuration file.
    Dylan Bruschi #2447

  • colon rule now catches violations when declaring generic types with inheritance or protocol conformance.
    Marcelo Fabri #2628

  • discarded_notification_center_observer rule now checks if the observer is added to any collection or passed to a function before triggering the violation.
    jsloop42 #2684

  • Fix false positives on number_separator when the number is wrapped in parentheses.
    Dalton Claybrook #2683

  • Fix false positives on sorted_first_last when calling firstIndex and lastIndex method. Taiki Komaba #2700

  • Fix crash when running on Linux with Swift 5 without specifying a --path value or specifying an empty string.
    Keith Smiley #2703

  • Fix false positives on explicit_acl and explicit_top_level_acl rules when declaring extensions that add protocol conformances with Swift 5.
    Marcelo Fabri #2705

  • Let disable all command override superfluous_disable_command rule.
    Frederick Pietschmann #2670

  • Fix issues in explict_acl, redundant_set_access_control and explicit_top_level_acl rules when using Swift 5.
    Marcelo Fabri #2694

0.31.0: Busy Laundromat -


  • None.


  • None.


  • Add deployment_target rule to validate that @availability attributes and #available conditions are not using a version that is satisfied by the deployment target. Since SwiftLint can't read an Xcode project, you need to configure this rule with these keys: iOS_deployment_target, macOS_deployment_target, watchOS_deployment_target and tvOS_deployment_target. By default, these values are configured with the minimum versions supported by Swift.
    Marcelo Fabri #2589

  • Add weak_computed_property rule to warn against using weak in a computed property as it has no effect.
    Marcelo Fabri #2596

  • Add SwiftVersion.five and automatically detect it when computing SwiftVersion.current.
    JP Simard

  • Make redundant_objc_attribute rule autocorrectable.
    Daniel Metzing

  • Add required_deinit opt-in rule to ensure that all classes have a deinit method. The purpose of this is to make memory leak debugging easier so all classes have a place to set a breakpoint to track deallocation.
    Ben Staveley-Taylor #2620

  • nimble_operator now warns about beTrue() and beFalse().
    Igor-Palaguta #2613

  • Warn if a configured rule is not enabled.
    Marcelo Fabri #1350

  • Add exclude_ranges option to number_separator for exclusion.
    Cihat Gündüz #2637

Bug Fixes

  • Fix false positives on no_grouping_extension rule when using where clause.
    Almaz Ibragimov

  • Fix explicit_type_interface when used in statements.
    Daniel Metzing #2154

  • Fix lower_acl_than_parent when linting with Swift 5.
    JP Simard #2607

  • Fix let_var_whitespace with #warning.
    Igor-Palaguta #2544

  • Fix excessive superfluous_disable_command violations being reported when using an invalid rule identifier in a disable command.
    Marcelo Fabri #2623

  • Fix explicit_type_interface with allow_redundancy when assigning type references to variables.
    Cihat Gündüz #2636

  • Fix unused_closure_parameter when argument is named self.
    Cihat Gündüz #2437

  • Fix first_where for some calls on Realm collection types.
    Cihat Gündüz #1930

0.30.1: Localized Stain Remover -


  • None.


  • Silence CodingKeys violations in unused_private_declaration since these should always be intentional violations.
    Kim de Vos #2573


  • Add nslocalizedstring_key opt-in rule to validate that keys used in NSLocalizedString calls are static strings, so genstrings will be able to find them.
    Marcelo Fabri

Bug Fixes

  • Fix false positives on trailing_closure rule when using anonymous closure calls.
    Marcelo Fabri #2159

  • Fix false positives on array_init rule when using prefix operators.
    Marcelo Fabri #1877

  • Exclude files defined in the excluded value of SwiftLint's configuration when --use-script-input-files and --force-exclude are specified.
    Luis Valdés #591

0.30.0: A New Washer and Dryer Set -


  • None.


  • None.


  • Add duplicate_imports rule to prevent importing the same module twice.
    Samuel Susla #1881

  • Add unused_setter_value rule to validate that setter arguments are used in properties.
    Marcelo Fabri #1136

  • Add only_single_muted_parameter configuration on trailing_closure rule to only enforce using trailing closure on functions that take one single muted parameter.
    Marcelo Fabri

Bug Fixes

  • Fix false positives on identical_operands rule when the right side of the operand has a chained optional.
    JP Simard #2564

0.29.4: In-Unit Operands -


  • None.


  • Fix unused_import correction deleting unrelated ranges when there are multiple violations in a single file.
    JP Simard #2561


  • Add strong_iboutlet opt-in rule to enforce that @IBOutlets are not declared as weak.
    Marcelo Fabri #2433

Bug Fixes

  • Fix inaccessible custom rules in nested configurations.
    Timofey Solonin #1815 #2441

  • Improve superfluous_disable_command to warn against disabling non-existent rules.
    Kim de Vos #2348

  • Fix false positives on identical_operands rule when the right side of the operand does not terminate.
    Xavier Lowmiller #2467

0.29.3: Entangled Agitator -


  • None.


  • Skip @IBInspectable and deinit declarations in unused_private_declaration.
    JP Simard


  • Allow configuring discouraged_object_literal rule to only discourage one kind of object literal.
    Marcelo Fabri #2439

  • Adds xct_specific_matcher opt-in rule to enforce specific matchers over XCTAssertEqual and XCTAssertNotEqual.
    Ornithologist Coder #1874

  • Add last_where opt-in rule that warns against using .filter { /* ... */ }.last in collections, as .last(where: { /* ... */ }) is more efficient.
    Marcelo Fabri

  • Add unused_control_flow_label rule to validate that control flow labels are used.
    Marcelo Fabri #2227

Bug Fixes

  • Fix false positives on first_where rule when calling filter without a closure parameter (for example on a Realm collection).
    Marcelo Fabri

  • Fix false positives on sorted_first_last rule when calling sorted with a different argument than by: (e.g. on a Realm collection).
    Marcelo Fabri #2533

  • Fix false positives on redundant_objc_attribute rule when using nested types.
    Marcelo Fabri #2539

  • Fix false positives on vertical_whitespace_between_cases rule when a blank line is present but it contains trailing whitespace.
    Ben Staveley-Taylor #2538

0.29.2: Washateria -


  • None.


  • None.


  • Add new opt-in rule vertical_whitespace_opening_braces to warn against empty lines after opening braces.
    Cihat Gündüz #1518

  • Add new opt-in rule vertical_whitespace_closing_braces to warn against empty lines before closing braces.
    Cihat Gündüz #1518

  • Improve performance for unused_private_declaration and unused_import rules for large files.
    Niil Öhlin

  • Add new legacy_hashing rule to encourage the use of Swift 4.2's new hashing interface.
    Kim de Vos #2108

  • Improve private_unit_test rule to allow private classes with @objc attribute.
    Kim de Vos #2282

  • Support glob patterns without the star.
    Maksym Grebenets

  • Make modifier_order rule autocorrectable.
    Timofey Solonin #2353

Bug Fixes

  • Fix false positives in redundant_objc_attribute for private declarations under @objcMembers.
    Daniel Metzing #2499

  • Fix an error when pulling SwiftLint as a dependency using Carthage.
    JP Simard

  • Non-string values specified in swiftlint_version now fail the lint if it doesn't match the version.
    JP Simard #2518

0.29.1: There’s Always More Laundry -


  • None.


  • None.


  • Add redundant_objc_attribute to warn against already implied @objc attribute.
    Daniel Metzing #2193

  • Add vertical_whitespace_between_cases opt-in rule to enforce a single empty line between switch cases.
    Cihat Gündüz #1517

  • Add multiline_arguments_brackets opt-in rule to warn against multiline function call arguments with surrounding brackets without newline.
    Cihat Gündüz #2306

  • Add multiline_literal_brackets opt-in rule to warn against multiline literal arrays & dictionaries with surrounding brackets without newline.
    Cihat Gündüz #2306

  • Add multiline_parameters_brackets opt-in rule to warn against multiline function definition parameters with surrounding brackets without newline.
    Cihat Gündüz #2306

  • Ignore unspecified modifiers in modifier_order.
    Timofey Solonin #2435

  • The lint command now exits with a code of 2 when not using pinned version defined as swiftlint_version in the configuration file.
    Kim de Vos #2074

Bug Fixes

  • Fix false positive in nimble_operator rule.
    Marcelo Fabri #2489

  • Fix false positives on explicit_type_interface rule when configured with option allowRedundancy set to true.
    Cihat Gündüz #2425

  • Only mark custom rules as 'enabled in your config' in the output of the rules command when there are one or more configured custom rules.

  • Fix wrong correction when removing testable imports with the unused_import rule.
    JP Simard

  • Fix false positive with the unused_import rule when importing Foundation when there are attributes in that file requiring Foundation.
    JP Simard

0.29.0: A Laundry List of Changes -


  • SwiftLint now requires Swift 4.2 or higher to build.
    JP Simard


  • None.


  • Improve the performance of saving or reading cached lint results on platforms with CommonCrypto.
    JP Simard

  • Add markdown reporter which outputs markdown-formatted tables, ideal for rendering in GitLab or GitHub.
    Dani Vela

  • Add testSimulateHomebrewTest() to IntegrationTests that simulates test in homebrew-core/Formula/swiftlint.rb within sandbox.
    Norio Nomura

Bug Fixes

  • Fix compiler warnings when building with Swift 4.2 introduced in the last release.
    JP Simard

  • Fix false positive in explicit_init rule.
    Dominic Freeston

  • Fix toggle_bool false positive violation when comparing object parameter to an equally named variable.
    Timofey Solonin #2471

  • Fix false positive on file_name rule with specific patterns.
    Cihat Gündüz #2417

  • Fix crash in no_fallthrough_only and potentially other rules when linting files with unicode characters in certain locations.
    JP Simard #2276

  • Fix violations with no character/column location not being reported in xcpretty. Now violations with no column location default to a column value of 1 indicating the start of the line.
    JP Simard #2267

0.28.2: EnviroBoost Plus -


  • None.


  • None.


  • Add SWIFTLINT_DISABLE_SOURCEKIT environment variable to allow running SwiftLint without connecting to SourceKit. This will run a subset of rules that don't require SourceKit, which is useful when running in a sandboxed setting such as in Homebrew's CI.
    Norio Nomura

Bug Fixes

  • None.

0.28.1: EnviroBoost -

This is the last release to support building with Swift 4.0 and Swift 4.1.


  • None.


  • None.


  • None.

Bug Fixes

  • Improve the performance of collecting which files to lint by up to 3.5x.
    JP Simard

  • Improve the performance of looking up cached lint results by up to 10x for complex configurations.
    JP Simard

0.28.0: EcoBoost -


  • Completely remove the --use-tabs option of the autocorrect command that was deprecated in 0.24.1. In its place, define an indentation key in your configuration files.
    JP Simard


  • Add a new swiftlint analyze command which can lint Swift files using the full type-checked AST. Rules of the AnalyzerRule type will be added over time. The compiler log path containing the clean swiftc build command invocation (incremental builds will fail) must be passed to analyze via the --compiler-log-path flag. e.g. --compiler-log-path /path/to/xcodebuild.log
    JP Simard

  • Add an explicit_self analyzer rule to enforce the use of explicit references to self. when accessing instance variables or functions.
    JP Simard #321

  • Add an unused_import analyzer rule to lint for unnecessary imports.
    JP Simard #2248

  • Add an unused_private_declaration analyzer rule to lint for unused private declarations.
    JP Simard


  • Add legacy_random opt-in rule to encourage the use of .random(in:) instead of arc4random, arc4random_uniform, and drand48.
    Joshua Kaplan

  • Improve performance of line_length and multiple_closures_with_trailing_closure rules.
    Marcelo Fabri

  • Add closure_body_length opt-in rule to enforce the maximum number of lines a closure should have. Requires Swift 4.2.
    Ornithologist Coder #52

  • Add SonarQube reporter.
    Yusuke Ohashi #2350

  • Add prohibited_interface_builder opt-in rule to validate that @IBOutlets and @IBActions are not used.
    Marcelo Fabri #2365

  • Add inert_defer rule to validate that defer is not used at the end of a scope.
    Marcelo Fabri #2123

  • Add toggle_bool opt-in rule which suggests using someBool.toggle() over someBool = !someBool. Requires Swift 4.2.
    Dalton Claybrook #2369

  • Add identical_operands opt-in rule to validate that operands are different expressions in comparisons.
    Marcelo Fabri #1371

  • Add collection_alignment opt-in rule to validate that all elements in a collection literal are aligned vertically.
    Dalton Claybrook #2326

  • Add static_operator opt-in rule to enforce that operators are declared as static functions instead of free functions.
    Marcelo Fabri #2395

  • Specify what type of compiler protocol initializer violated the compiler_protocol_init rule.
    Timofey Solonin #2422

Bug Fixes

  • Fix comma rule false positives on object literals (for example, images).
    Marcelo Fabri #2345

  • Fix false positive on file_name rule when using nested types.
    Marcelo Fabri #2325

  • Fix crash on multiline_function_chains rule when using some special characters inside the function calls.
    Marcelo Fabri #2360

  • Change autocorrect --format to run format before autocorrect, fixing conflicts between default indentation and rules which modify indentation (i.e. closure_end_indentation).
    Ornithologist Coder #2374

  • Fix false positive on empty_count rule when assessing binary, octal and hexadecimal integer literals.
    Timofey Solonin #2423

0.27.0: Heavy Duty -


  • None.


  • Append modifier_order description with failure reason.
    Daniel Metzing #2269

  • Decrease default severity of superfluous_disable_command to warning.
    Frederick Pietschmann #2250

  • Don't touch files when running autocorrect --format if the contents haven't changed.
    Marcelo Fabri #2249

  • Add only_enforce_after_first_closure_on_first_line configuration to multiline_arguments
    Mike Ciesielka #1896

  • Add anyobject_protocol opt-in rule which suggests using AnyObject over class for class-only protocols.
    Ornithologist Coder #2283

  • Add options prefix_pattern and suffix_pattern to rule file_name.
    Cihat Gündüz #2309

  • Add new bool config option if_only to rule conditional_returns_on_newline to specify that the rule should only be applied to if statements.
    Cihat Gündüz #2307

  • Add support for globs in excluded file paths.
    Keith Smiley #2316

  • Add only_private configuration to prefixed_toplevel_constant rule.
    Keith Smiley #2315

  • Make rule explicit_type_interface compatible with rule redundant_type_annotation via new option allow_redundancy.
    Cihat Gündüz #2312

  • Add missing_docs rule to warn against undocumented declarations.
    Nef10 Andrés Cecilia Luque #1652

Bug Fixes

  • Fix an issue with control_statement where commas in clauses prevented the rule from applying.
    Allen Wu

  • Fix explicit_enum_raw_value, generic_type_name, implicit_return, required_enum_case, quick_discouraged_call, array_init, closure_parameter_position and unused_closure_parameter rules when linting with Swift 4.2.
    Marcelo Fabri

  • Fix identifier_name rule false positives with enum when linting using Swift 4.2.
    Marcelo Fabri Jacob Greenfield #2231

  • Fix a crash when running with Swift 4.2.
    Norio Nomura SR-7954

  • Fix false positive on attributes rule when linting a line that is below a line with a declaration that has attributes.
    Marcelo Fabri #2297

  • redundant_optional_initialization rule now lints local variables.
    Marcelo Fabri #2233

  • Fix autocorrection for redundant_type_annotation rule.
    Marcelo Fabri #2314