SwiftLint v0.28.0 Release Notes

  • ๐Ÿ’ฅ Breaking
    • ๐Ÿšš 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
    Experimental
    • โž• 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

    โœจ Enhancements
    • โž• 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