Skip to content

Releases: realm/SwiftLint

0.38.2: Machine Repair Manual

08 Jan 18:35
76d44cf
Compare
Choose a tag to compare

Breaking

  • None.

Experimental

  • None.

Enhancements

  • 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.
    pyrtsa

  • 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

04 Jan 03:45
6f6c9fe
Compare
Choose a tag to compare

Breaking

  • None.

Experimental

  • None.

Enhancements

  • Make weak_delegate rule correctable.
    MaxHaertwig

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

  • 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

03 Dec 18:51
8dc3e81
Compare
Choose a tag to compare

Breaking

  • 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

Experimental

  • None.

Enhancements

  • Make control_statement rule correctable.
    MaxHaertwig

  • 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

09 Nov 22:32
36775cc
Compare
Choose a tag to compare

Breaking

  • 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

Experimental

  • None.

Enhancements

  • 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.
    PaulTaykalo
    #2916

  • 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: 👕👚👗

24 Oct 22:26
652e5dd
Compare
Choose a tag to compare

Breaking

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

Experimental

  • None.

Enhancements

  • 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.
    MaxHaertwig

  • 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

03 Sep 14:08
8dc8421
Compare
Choose a tag to compare

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

Breaking

  • None.

Experimental

  • None.

Enhancements

  • 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

19 Jul 01:37
08946e6
Compare
Choose a tag to compare

Breaking

  • 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

Experimental

  • 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

Enhancements

  • None.

Bug Fixes

  • None.

0.33.1: Coin-Operated Property Wrapper

08 Jul 15:56
ffd0804
Compare
Choose a tag to compare

Breaking

  • None.

Experimental

  • None.

Enhancements

  • 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

02 Jun 17:08
Compare
Choose a tag to compare

Breaking

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

Experimental

  • None.

Enhancements

  • 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:

    $ SWIFTLINT_FRAMEWORK_TEST_ENABLE_SIMULATE_HOMEBREW_TEST=1 \
    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

29 Apr 04:44
6534946
Compare
Choose a tag to compare

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.

Breaking

  • None.

Experimental

  • None.

Enhancements

  • 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