0.50.0-rc.2: Artisanal Clothes Pegs
Pre-releaseThis is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install:
- Downloading the attached
SwiftLint.pkginstaller and launching it - Downloading the attached
portable_swiftlint.ziparchive, extracting it and moving the binary fromportable_swiftlint/swiftlintto/usr/local/binor elsewhere in yourPATH - Using Mint:
mint install realm/SwiftLint@0.50.0-rc.2 - Cloning and building from source:
git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.2 && make install - Docker:
docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.2 - Bazel: See instructions at the bottom
Changes from 0.49.1: 0.49.1...0.50.0-rc.2
Changes from 0.50.0-rc.1: 0.50.0-rc.1...0.50.0-rc.2
Breaking
-
SwiftLint now requires Swift 5.7 or higher to build.
JP Simard -
Exclude
weak_delegaterule from autocorrection due to behavioral changes
leading to potential undefined behavior or bugs.
SimplyDanny
#3577 -
The
anyobject_protocolrule is now deprecated and will be completely removed
in a future release because it is now handled by the Swift compiler.
JP Simard
Experimental
- None.
Enhancements
-
SwiftSyntax libraries have been updated from the previous 5.6 release and now
use the new parser written in Swift.
Swift 5.7+ features should now be parsed more accurately.
We've also measured an improvement in lint times of up to 15%.
This should also fix some deployment issues where the exact version of the
internal SwiftSyntax parser needed to be available.
If you notice any unexpected changes to lint results, please file an issue on
the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax
parser regression we can re-file it upstream.
JP Simard
#4031 -
Add ability to filter rules for
generate-docssubcommand.
kattouf -
Add new
excludes_trivial_initconfiguration formissing_docsrule
to exclude initializers without any parameters.
Marcelo Fabri
#4107 -
Rewrite some rules with SwiftSyntax, fixing some false positives and catching
more violations:anonymous_argument_in_multiline_closurearray_initattributesblock_based_kvoclass_delegate_protocolclosing_braceclosure_body_lengthclosure_parameter_positioncomputed_accessors_orderconditional_returns_on_newlinecontains_over_filter_countcontains_over_filter_is_emptycontains_over_first_not_nilcontains_over_range_nil_comparisondeployment_targetdiscouraged_assertdiscouraged_direct_initdiscouraged_none_namediscouraged_object_literaldiscouraged_optional_booleanduplicate_enum_casesdynamic_inlineempty_collection_literalempty_enum_argumentsempty_parametersempty_parentheses_with_trailing_closureempty_stringenum_case_associated_values_countexplicit_enum_raw_valueexplicit_initfallthroughfirst_whereflatmap_over_map_reduceforce_tryforce_unwrappingfunction_body_lengthfunction_default_parameter_at_endfunction_parameter_countgeneric_type_nameibinspectable_in_extensionidentical_operandsimplicit_getterimplicitly_unwrapped_optionalinert_deferis_disjointlarge_tuplelast_wherelegacy_cggeometry_functionslegacy_constantlegacy_constructorlegacy_hashinglegacy_multiplelegacy_nsgeometry_functionslegacy_randommultiple_closures_with_trailing_closureno_extension_access_modifierno_fallthrough_onlyno_space_in_method_callnslocalizedstring_require_bundlensobject_prefer_isequalnumber_separatoroperator_whitespacensobject_prefer_isequalprivate_actionprivate_over_fileprivateprivate_outletprivate_unit_testprohibited_interface_builderprotocol_property_accessors_orderquick_discouraged_focused_testquick_discouraged_pending_testreduce_booleanredundant_discardable_letredundant_nil_coalescingredundant_string_enum_valueself_in_property_initializationshorthand_operatorsorted_first_laststatic_operatorstrict_fileprivatestrong_iboutletswitch_case_alignmentswitch_case_on_newlinetoggle_booltrailing_commatrailing_semicolontype_body_lengthunneeded_break_in_switchunneeded_parentheses_in_closure_argumentunowned_variable_captureuntyped_error_in_catchunused_closure_parameterunused_control_flow_labelunused_enumeratedunused_setter_valuevalid_ibinspectableweak_delegatexctfail_message
Marcelo Fabri
SimplyDanny
JP Simard
#2915
-
The "body length" family of rules have changed how they calculate body
line count to be significantly more correct and intuitive. However,
this is likely to require adjustments to your configuration or disable
commands to account for the changes.
JP Simard -
Add
accessibility_trait_for_buttonrule to warn if a SwiftUI
View has a tap gesture added to it without having the button or
link accessibility trait.
Ryan Cole -
Add methods from SE-0348 to
UnusedDeclarationRule.
JP Simard -
Include the configured
bind_identifierinself_bindingviolation
messages.
JP Simard -
Add
library_content_providerfile type tofile_types_orderrule
to allowLibraryContentProviderto be ordered independent frommain_type.
dahlborn -
Add
test_parent_classesoption totest_case_accessibilityrule, which
allows detection in subclasses of XCTestCase.
Martin Redington
#4200 -
Add a new
shorthand_optional_bindingopt-in rule that triggers in Swift 5.7
when a shadowing optional binding is created in aniforguardstatement.
SimplyDanny
#4202 -
Use SwiftSyntax instead of SourceKit to determine if a file has parser errors
before applying corrections. This speeds up corrections significantly when
none of the rules use SourceKit.
JP Simard -
Add Swift Package Build Tool Plugin with support for Swift Packages
and Xcode projects.
Johannes Ebeling
#3679
#3840 -
Make
private_unit_testrule correctable.
SimplyDanny -
Disregard whitespace differences in
identical_operandsrule. That is, the rule
now also triggers if the left-hand side and the right-hand side of an operation
only differ in trivia.
SimplyDanny -
Print violations in realtime if
--progressand--outputare both set.
JP Simard
Bug Fixes
-
Respect
validates_start_with_lowercaseoption when linting function names.
Chris Brakebill
#2708 -
Do not report variables annotated with
@NSApplicationDelegateAdaptorand
@WKExtensionDelegateAdaptorinweak_delegaterule.
Till Hainbach
#3598
#3611 -
Fix false-positives related to the
willMovelifecycle method in
type_contents_orderrule.
SimplyDanny
#3478 -
Do no longer autocorrect usage of
NSIntersectionRectinlegacy_nsgeometry_functions
rule.
SimplyDanny
#3703 -
Fix Analyzer rules in Xcode 14.
SimplyDanny
#4208 -
Add column for SourceKit usage to
rulescommand.
JP Simard -
Make
nsobject_prefer_isequalrule work for nested@objcclasses. Also consider
the@objcMembersannotation.
SimplyDanny -
Print fixed content at most once to STDOUT.
SimplyDanny
#4211 -
Fix fatal error when content given via STDIN is corrected in the
trailing_newlinerule.
SimplyDanny
#4234
Using Bazel
Put this in your WORKSPACE:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "973587995aab45ac56b963c1768a830a6a66580ccea4d5bf81617106b22bfa3f",
url = "https://github.com/realm/SwiftLint/releases/download/0.50.0-rc.2/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help