Commit Graph

92 Commits

Author SHA1 Message Date
JP Simard 759408fdb5
Update SwiftSyntax (#4506)
This update pulls in https://github.com/apple/swift-syntax/pull/1050,
which fixes a memory leak, reducing memory usage by up to 3x and
improves lint times by 20%-50% in my tests.
2022-11-04 06:05:38 -04:00
github-actions[bot] 6ad4a704f5
Update SwiftSyntax (#4497) 2022-10-31 09:49:40 -04:00
JP Simard d551cb8c16
Update SwiftSyntax (#4480)
Moves syntax classifications to a new IDEUtils module.
2022-10-28 09:23:06 -04:00
github-actions[bot] 7738f0c0a5
Update SwiftSyntax (#4476)
Co-authored-by: jpsim <jpsim@users.noreply.github.com>
2022-10-24 17:10:17 -04:00
JP Simard 1ee5154687
Update SwiftSyntax to `fa7ff05` (#4455)
There's a new SwiftParserDiagnostics module and the rewriter visit
function signatures changed.
2022-10-23 11:56:22 -04:00
JP Simard 401d0f7929
Update SwiftSyntax to `60c7037` (#4454)
This has changes to how comments are associated to nodes.

See https://github.com/apple/swift-syntax/pull/985
2022-10-23 11:15:27 -04:00
JP Simard e84430f222
Update SwiftSyntax (#4431) 2022-10-20 13:16:00 -04:00
JP Simard 25c9d34f5a
Update SwiftSyntax (#4429) 2022-10-20 09:21:14 -04:00
JP Simard 8ec6e0eefc
Update SwiftSyntax (#4398)
https://github.com/apple/swift-syntax/pull/938 was impacting some
corrections in Lyft's codebase.
2022-10-17 09:42:02 -04:00
JP Simard 33f6ee1f36
Update SwiftSyntax (#4363)
Noteworthy:

* https://github.com/apple/swift-syntax/pull/912
* https://github.com/apple/swift-syntax/pull/932
2022-10-13 10:28:00 -04:00
JP Simard 602070164b
Reduce memory usage (#4349)
When linting SwiftLint, this brings memory usage down by around 20%,
going from 372MB to 297MB.

This is achieved by removing the unused `RebuildQueue` and by clearing
cached data associated with files after processing them.

Depends on https://github.com/jpsim/SourceKitten/pull/749.
2022-10-12 09:39:36 -04:00
JP Simard 87e9757af2
Update SwiftSyntax (#4346)
I think there might have been changes impacting the `static_operator`
rule, so I want to look more into those here.

Remove workaround for https://github.com/apple/swift-syntax/issues/888
2022-10-11 21:12:29 -04:00
JP Simard d6fd754679
Rewrite `contains_over_range_nil_comparison` with SwiftSyntax (#4225)
Use SwiftOperators.
2022-10-06 01:18:31 -04:00
JP Simard 5ae1d98596
Create new GeneratedTests and IntegrationTests test targets (#4304)
* Move generated rule tests to a dedicated GeneratedTests target
* Move integration tests to a dedicated IntegrationTests target

This will improve bazel cacheability by having fewer tests depend on all
lint inputs, which are only needed by the integration tests.
2022-10-06 00:10:04 -04:00
JP Simard 503f8c506b
Move ExtraRulesTests to its own target & directory (#4300)
Also create a SwiftLintTestHelpers test target.
2022-10-05 23:36:46 -04:00
JP Simard 54ccc39e72
Update SwiftSyntax (#4290)
Just staying up to date here.

There's no need to frequently update, but given that we just updated to
trunk, I wanted to make sure we can update without issues.
2022-10-05 16:28:56 -04:00
Johannes Ebeling 3fd1573c57
Make SwiftLint available as a build tool plugin (#4176)
*  (spm) add build tool plugin definition for swiftlint
* 📝 (changelog) add changelog item for the plugin
* 🐛 (cache) define cache path explicitly to avoid issues during build without issues
* 🎨 minor code cleanup
* 📝 document usage with Xcode as well as Swift packages
2022-10-05 15:28:19 -04:00
Vasiliy Kattouf 129a55fb74
Add ability to filter rules for `generate-docs` subcommand (#4195)
Added rules filtering options, like in the `rules` subcommand.

<img width="880" alt="generate-docs--help" src="https://user-images.githubusercontent.com/7829589/189372666-2f5aba62-57a1-49dc-9155-c60f9e085984.png">

To achieve reuse with `rules` subcommand:
- extracted filtering logic into `RulesFilter` (and write tests)
- extracted filtering command line parameters into `RulesFilterOptions: ParsableArguments`
2022-10-04 18:45:52 +00:00
JP Simard 2388e49190
Use SwiftSyntax's new SwiftParser (#4216) 2022-10-01 15:05:36 -04:00
JP Simard 86f6023d13
Update CryptoSwift to 1.6.0 release (#4258) 2022-09-28 23:37:54 -04:00
JP Simard fd7afedfcf
Update SwiftSyntax & internal parser for Swift 5.7 (#4203)
Require Swift 5.7 to compile
2022-09-26 14:11:39 +00:00
JP Simard 4234664671
Rewrite `anyobject_protocol` with SwiftSyntax & deprecate (#4170) 2022-09-07 19:40:34 +00:00
JP Simard 21ba7c8280
Update SourceKitten to 0.33.0 (#4085)
https://github.com/jpsim/SourceKitten/releases/tag/0.33.0
2022-08-11 21:04:32 +00:00
JP Simard a97718f4c6
Replace incrementer dispatch queue with an actor (#4073)
To support this, we first must use an async entrypoint to the CLI, which
we do by changing the lint and analyze commands to conform to
`AsyncParsableCommand`.

The in order to map over the closures with suspension points, we pull in
CollectionConcurrencyKit as a new dependency.

This change does not touch SwiftLintFramework, only the CLI target.
2022-08-09 13:06:08 +00:00
JP Simard 05ac3c9d75
Require macOS 12 & Swift 5.6 (#4037)
This will unblock using Swift Concurrency features and updating to the
latest versions of Swift Argument Parser.

This won't drop support for linting projects with an older toolchain /
Xcode selected, as long as SwiftLint was _built_ with 5.6+ and is
_running_ on macOS 12+. So the main breaking change for end users here
is requiring macOS 12 to run.

However, the upside to using Swift Concurrency features is worth the
breaking change in my opinion. Also being able to stay on recent Swift
Argument Parser releases.
2022-07-26 03:55:36 -04:00
Danny Mösch 1faea36a22
Do not trigger unavailable_condition rule if other #(un)available checks are involved (#4002) 2022-06-24 22:58:02 +02:00
JP Simard a256fa2c8c
Bump SwiftSyntax to latest release (#3907)
Fixes https://github.com/realm/SwiftLint/issues/3906

Going from 0.50600.0 to 0.50600.1
2022-03-18 11:59:35 -04:00
JP Simard de3569cb3b
Update SwiftSyntax to 0.50600.0 (#3901)
Uses SwiftSyntax 5.5 on Linux when building with Swift 5.5. We use the 5.6 version of
SwiftSyntax when building with Swift 5.5 and 5.6 on macOS because we statically link
`lib_InternalSwiftSyntaxParser` thanks to
https://github.com/keith/StaticInternalSwiftSyntaxParser/releases/tag/5.6.

This keeps SwiftLint binaries portable across machines on macOS, regardless of
_where_ or even _if_ `lib_InternalSwiftSyntaxParser` is installed.

* Run TSan CI job with `--configuration release` to avoid stack overflows
* Add Swift 5.6 CI job
* Fix linker settings
2022-03-17 13:19:48 -04:00
JP Simard 84bc2174af
Bump dependencies (#3900)
SourceKitten: 0.31.1 to 0.32.0
SWXMLHash: 5.0.2 to 6.0.0

Also prevent swift-argument-parser from being updated to 1.1.0 which is
incompatible with our macOS version support.
2022-03-15 17:17:42 -04:00
JP Simard 1abc50304c
Use alternate implementation of glob with globstar support (#3892)
Adapted from https://gist.github.com/efirestone/ce01ae109e08772647eb061b3bb387c3

The implementation from Pathos seems buggy.

Fixes https://github.com/realm/SwiftLint/issues/3891
2022-03-11 13:24:39 -05:00
Fumito Nakazawa 2ae22d06a2
Support recursive globs (#3843)
ref: https://github.com/realm/SwiftLint/issues/3789

## Overview
Support glob recursive by using [Pathos](https://github.com/dduan/Pathos)
- Introduce Pathos
- Replace glob logic
- Fix some test cases
2022-03-10 21:56:43 -05:00
JP Simard a43e52aa91
Integrate Swift Syntax in the `force_cast` rule (#3867)
We've tried adding Swift Syntax support to SwiftLint in the past but had to turn it off in https://github.com/realm/SwiftLint/pull/3107 due to distribution and portability issues.

With https://github.com/keith/StaticInternalSwiftSyntaxParser it should be possible to avoid those issues by statically linking the internal Swift syntax parser so it's available no matter where users have Xcode installed on their computer.

By removing all calls to SourceKit (collecting comment commands + checking the current Swift version), there's a really significant performance improvement.

| Framework | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| SourceKit | 517.8 ± 8.3 | 505.5 | 531.1 | 6.59 ± 0.43 |
| SwiftSyntax | 78.6 ± 5.0 | 72.6 | 92.1 | 1.00 |

In practice, the SourceKit overhead will continue being there for as long as any rule being run is still looking up the SwiftLint syntax map though.
2022-03-07 12:51:24 -05:00
JP Simard be1f8596e4
Require Swift 5.5 to build SwiftLint (#3869)
* Disable Swift 5.4 CI jobs
* Remove SwiftLintFramework podspec
  I couldn't find a single use in GitHub's search: https://github.com/search?q=SwiftLintFramework+filename%3APodfile+language%3ARuby+language%3ARuby&type=Code
  Just not worth maintaining anymore.
* Change package swift tools version to 5.5
* Update docker_test to use Swift 5.5 image
* Clean up old Swift versions in SwiftVersionTests
  Even though these older Swift versions should still be supported, these tests
  can't be built against those versions so they're useless.
* Run docker commands with `--platform linux/amd64`
* Remove LinuxMain
  It looks like tests are discovered dynamically on Linux as of recent
  SwiftPM versions.
2022-03-07 12:15:03 -05:00
Takuhiro Muta 867fc1a34c
Update CryptoSwift to 1.4.3 (#3861) 2022-02-19 12:48:11 -05:00
uhooi b621fb128f
Bump Swift Argument Parser and SourceKitten (#3733) 2021-10-05 22:00:14 -04:00
leogdion 3643fea111
adding platform specification to Swift package (#3482) 2021-02-23 13:29:55 -08:00
JP Simard fa55508668
Migrate from Commandant to swift-argument-parser 2020-12-14 15:51:04 -05:00
JP Simard e7f4a8fd67
Update SourceKittenFramework to 0.31.0 2020-12-14 15:51:04 -05:00
JP Simard 9c672c774c
Update Yams 2020-12-11 11:20:00 -05:00
JP Simard 45f7aaa961
Update CryptoSwift to 1.3.2 2020-11-08 12:30:59 -05:00
JP Simard 15c25abc47
Update SourceKitten to 0.30.1 (#3367) 2020-09-23 08:34:46 -07:00
JP Simard 81e8501dd5
Update SourceKitten and Yams 2020-08-24 22:27:13 -04:00
JP Simard b744cf08f1
Temporarily remove all SwiftSyntax rules and support (#3107)
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`

See https://github.com/realm/SwiftLint/issues/3105 for details.
2020-02-11 13:40:04 -08:00
Marcelo Fabri 8d9c501cb8
Add optional return_value_from_void_function rule using SwiftSyntax (#3054)
* Add optional return_value_from_void_function rule using SwiftSyntax

* Use Script/bootstrap in CI

* Make SwiftSyntax optional

* Make SwiftSyntax optional in SPM

* Fix Package.swift

* Try again

* Add minSwiftVersion

* Fix thread sanitizer issue

* Take 2

* Fix false positive on nested computed variables

* Remove support for Xcode 10.x

* Fix rule description

* Enable opt-in rule in configuration file

* Extract code into `SyntaxRule` protocol

* nit: make property private

* Missing docs

* Fix MasterRuleList.swift

* Update CHANGELOG

* Remove unused imports

* Use Example type

* Change rule kind to .idiomatic

* Update CHANGELOG

* Bump deployment target to macOS 10.12

* Simplify SyntaxRule.validate(file:visitor)

* Make TSan happy

* Use script/bootstrap in the README
2020-02-08 02:43:40 -08:00
JP Simard fe5baca7cd
Migrate to use SourceKitten's new ByteCount/ByteRange types (#3037)
New APIs were introduced in SourceKitten to allow for a more typesafe distinction between integers meaning NSString-based distances and byte-based distances.

* https://github.com/jpsim/SourceKitten/pull/639
* https://github.com/jpsim/SourceKitten/pull/642

This PR migrates SwiftLint's use of those APIs.
2020-01-16 15:18:37 -08:00
JP Simard 40ade98710
Update SourceKitten to 0.28.0 (#3011) 2020-01-03 16:47:18 -08:00
JP Simard beaa2a8a87
Update Commandant and SourceKitten, drop Result (#2947) 2019-11-07 10:59:16 -08:00
Marcelo Fabri f7e0cc94e2 Lock CryptoSwift to 1.0.0 2019-10-14 00:16:56 -07:00
Marcelo Fabri e10a0129bc Set Swift version on Package.swift 2019-10-08 23:56:00 -07:00
Marcelo Fabri f5174b3168 Update SourceKitten to 0.26.0 2019-10-08 00:51:18 -07:00