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.
The option can be used if an example has mainly been added as another test case, but is not suitable
as a user example. User examples should be easy to understand. They should clearly show where and
why a rule is applied and where not. Complex examples with rarely used language constructs or
pathological use cases which are indeed important to test but not helpful for understanding can be
hidden from the documentation with this option.
* Change fingerprint generation to use relativeFile instead of location in order to support CI/CD on multiple machines.
* Created copy of location with relativeFile instead of file to generate fingerprint.
Co-authored-by: Henk Pors <hpors@anwb.nl>
While browsing the rules documentation, I noticed **many** rules were both in the Default Rules and in the Opt In Rules section.
After looking into it, the docs of the `drop(while predicate: (Element) throws -> Bool` function states:
A closure that takes an element of the sequence as its argument and returns true if the element should be skipped or false if it should be included. **Once the predicate returns false it will not be called again.**
This caused the `defaultRuleDocumentations` array to contain almost all `ruleDocumentation`.
Static references with `Self` are not allowed to define
* default values of properties,
* annotation parameter values and
* default method parameter values
in classes.
- Make "middle part" `.*` not so greedy with `?`.
- Use `(?!` negative look-ahead to improve matching.
- Added corresponding unit tests.
Co-authored-by: Sergei Shirokov <sshirokov@malwarebytes.com>