Commit Graph

5469 Commits

Author SHA1 Message Date
JP Simard a773c3ec21 Apply minor changes to the syntactic sugar rewrite (#3915)
* Improve docstrings for `StringView+SwiftSyntax.swift`
* Move changelog entry to correct section & reword
* Change parameter type from `Int` to `ByteCount`
* Move AbsolutePosition / ByteCount conversion to internal API
* Only warn once if syntax tree cannot be parsed
* Move Syntactic Sugar examples to a dedicated file
* Change SyntacticSugarRuleVisitor from SyntaxAnyVisitor to SyntaxVisitor
* Add `SugaredType` enum to help with the implement `SyntacticSugarRule`
2022-03-24 10:27:05 -04:00
JP Simard 9ace4bbb73 Don't pass --path to bundle install (#3918)
> [DEPRECATED] The `--path` flag is deprecated because it relies on
> being remembered across bundler invocations, which bundler will no
> longer do in future versions. Instead please use
> `bundle config set path 'vendor/bundle'`, and stop using this flag
2022-03-24 10:12:32 -04:00
Danny Moesch a801bbc83b Add new type-safe ArrayInitRule (#3914)
The idea of this new Analyzer rule is to filter the calls of `map` before they are passed on to the classic ArrayInitRule which does the detailed checking of the lambda function block. The rule makes sure that only the `map` function is considered that is defined by the `Sequence` protocol.
2022-03-23 22:29:50 +01:00
JP Simard 83a86870bb Fix false positives in unused_closure_parameter (#3916)
When using parameters with backticks.
2022-03-23 16:57:23 -04:00
Paul Taykalo d756541204 Rewrite SyntacticSugarRule using SwiftSyntax (#3866)
Rewrite SyntacticSugarRule with SwiftSyntax
2022-03-23 18:30:43 +02:00
JP Simard 206ff10e6e Add empty changelog section 2022-03-23 11:34:40 -04:00
JP Simard e5791ec16c release 0.47.0 0.47.0 2022-03-23 10:58:54 -04:00
Paul Taykalo 1616023b63 Add ability to run only one(focused) example (#3911)
* Add ability to focus on a specific test example

* Update CHANGELOG.md

Co-authored-by: JP Simard <jp@jpsim.com>

* Update CONTRIBUTING.md

Co-authored-by: JP Simard <jp@jpsim.com>

Co-authored-by: JP Simard <jp@jpsim.com>
2022-03-22 19:21:25 +02:00
JP Simard 702b36a781 Revert strip on Docker 2022-03-18 21:01:50 -04:00
JP Simard e06da98b6b fixup! fixup! Strip binary when building for release 2022-03-18 20:54:07 -04:00
JP Simard a59be8092d fixup! Strip binary when building for release 2022-03-18 20:44:53 -04:00
JP Simard 91b58c6cbe Strip binary when building for release
Shaves ~32% off the binary size.

Brings the universal fat binary on macOS from 86MB to 58MB.
2022-03-18 20:43:55 -04:00
Danny Moesch 12cda68ce2 Fix some typos and improve wording/style (#3910) 2022-03-18 17:42:25 -04:00
JP Simard 24bf129268 Run OSSCheck when Package.swift changes (#3909) 2022-03-18 17:13:21 -04: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 21bb280068 Build additional Docker image with Swift 5.5 (#3904)
* Build additional Docker image with Swift 5.5
* Build `swiftlint_linux_swift_5_5.zip`
2022-03-17 17:27:05 -04:00
JP Simard c44a3f4ff9 Add a changelog entry for IN_PROCESS_SOURCEKIT 2022-03-17 15:06:24 -04:00
JP Simard 402fe69f59 Add changelog entry for IN_PROCESS_SOURCEKIT 2022-03-17 15:05:11 -04:00
JP Simard 87d21e44e6 Edit wording in build phase Homebrew instructions 2022-03-17 13:31:04 -04:00
Michael Henry a129163053 Update applesilicon x brew fix Instruction (#3903) 2022-03-17 13:22:09 -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 ca2712aaee Make linux zip from GitHub's remote Docker image
Locally I had trouble building the image on both my previous Intel MacBook Pro
and my new M1 Max MacBook Pro.
2022-03-16 11:05:09 -04:00
Marcelo Fabri 0e5d838765 Support #unavailable in deployment_target rule (#3898)
Fixes #3896
2022-03-16 10:41:04 -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
Marcelo Fabri db2721f78e Require Swift 5.0 in runtime (#3886)
* Require Swift 5.0 in runtime

* Fix violation

* Enable legacy_rule by default

* Update changelog

* Fix changelog after rebase

* More cleanup
2022-03-11 14:01:27 -08:00
JP Simard c664c4f9e6 Move Buildkite pipeline config to repo (#3893)
These were previously defined in Buildkite itself.
2022-03-11 16:27:17 -05: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 92e199649d Fix make package command (#3890) 2022-03-10 20:00:49 -05:00
JP Simard 3273cef42b Prevent empty files from triggering rule violations (#3885)
There are many valid cases to have an empty Swift source files, and these
shouldn't trigger violations.
2022-03-09 16:09:11 -05:00
JP Simard eeba297f33 [Docs] Remove "experimental" label for analyzer rules (#3884)
These have been fairly stable for over two years at this point.
2022-03-09 14:45:09 -05:00
Marcelo Fabri b619154905 Automatically enforce min Swift version for all rules (#3881)
* Automatically enforce min Swift version for all rules

* Fix violations
2022-03-09 11:44:56 -08:00
tobias 811ca32c6d class_delegate_protocol: Add line break separator for protocol inheritance
clause to match format style with curly brackets on new line
2022-03-09 14:37:47 -05:00
JP Simard 0691a2e7e4 release 0.46.5 2022-03-08 16:35:33 -05:00
JP Simard ebaa6d2182 Add workaround for https://github.com/CocoaPods/CocoaPods/issues/11185 2022-03-08 16:33:17 -05:00
JP Simard 0f3de846d8 push to HEAD in make push_version 2022-03-08 16:18:20 -05:00
Danny Moesch 6fa8ff6070 Exclude examples with complex language constructs from the rule documentation (#3880) 2022-03-08 16:04:51 -05:00
Marcelo Fabri f9b9c35c1f Fix regression in trailing_closure rule with Swift 5.6 (#3879)
Fixes #3848
2022-03-08 12:52:07 -08:00
JP Simard 2ae6a55ba4 Fix regression in unused_import rule when using Swift 5.6 (#3878)
Fixes https://github.com/realm/SwiftLint/issues/3849
2022-03-08 13:15:39 -05:00
JP Simard 28dd673c48 Use SwiftSyntax visitor to parse commands (#3872)
* Cache SwiftSyntax syntax trees
* Use SwiftSyntax visitor to parse commands
* Update changelog entry
* Cache commands
2022-03-08 12:33:06 -05:00
Keith Smiley 0830eca24c Add -I to _InternalSwiftSyntaxParser on Linux (#3873)
Since `_InternalSwiftSyntaxParser` isn't in the search paths when building with the `-static-stdlib` flag, we have to manually pass an include path so the swift compiler discovers it. Unfortunately we cannot just pass `-I/usr/lib/swift` because that results in duplicate library errors since the libraries we're linking statically also live there as shared libraries. This first symlinks the module definition to the root of the checkout and uses `.` for the `-I`. Any temporary path could be used instead.
2022-03-08 08:49:24 -08:00
Marcelo Fabri 678c3483ed Fix regression in last_where rule with Swift 5.6 (#3874)
Fixes #3847
2022-03-08 07:53:56 -05:00
Marcelo Fabri 3f24998be5 Fix closure_parameter_position rule with Swift 5.6 (#3871)
Fixes #3845
2022-03-07 13:23:31 -08:00
Marcelo Fabri f19555f707 Fix empty_parentheses_with_trailing_closure with Swift 5.6 (#3870)
Fixes #3846
2022-03-07 13:39:57 -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
JP Simard d84be10e66 Add emmpty changelog section 2022-03-07 11:22:38 -05:00
JP Simard f3712b2b93 release 0.46.4 0.46.4 2022-03-07 11:15:27 -05:00
JP Simard ee7eee32b5 release 0.46.3 2022-03-07 11:15:03 -05:00
Marcelo Fabri ff4249856e Fix false positive in EmptyEnumArgumentsRule with Swift 5.6 (#3868)
Fixes #3850
2022-03-07 11:10:15 -05:00