Commit Graph

3222 Commits

Author SHA1 Message Date
JP Simard c1aeef7c27
WIP: SwiftParser
Disable failing tests
2022-09-06 11:33:21 -04:00
JP Simard 4b8a68072b
Call `super.visit` in `SyntaxRewriter` overrides (#4167)
As discussed in https://github.com/realm/SwiftLint/pull/4159#discussion_r962841482
2022-09-06 13:52:40 +00:00
JP Simard 26465f21ce
Add methods from SE-0348 to `UnusedDeclarationRule` (#4168)
https://github.com/apple/swift-evolution/blob/main/proposals/0348-buildpartialblock.md
2022-09-06 09:45:34 -04:00
Marcelo Fabri 622d48bd0a
Convert `unneeded_break_in_switch` to SwiftSyntax (#4164) 2022-09-05 20:32:29 -07:00
Marcelo Fabri b9e6a9aed8
Rewrite unneeded_parentheses_in_closure_argument with SwiftSyntax (#4159) 2022-09-05 06:12:33 -04:00
Marcelo Fabri 6c0413077c
Rewrite unowned_variable_capture with SwiftSyntax (#4161) 2022-09-05 05:38:29 -04:00
Marcelo Fabri 772e5f5806
Delegate Location init for AbsolutePosition to existing one (#4162) 2022-09-05 01:47:25 -04:00
Marcelo Fabri c7c4e0a1f3
Rewrite `implicit_getter` rule with SwiftSyntax (#4160)
* Rewrite `implicit_getter` rule with SwiftSyntax

* Handle different reason messages

* Add changelog + implicit return
2022-09-05 01:28:25 -04:00
Marcelo Fabri ca2d3a874f
Rewrite `large_tuple` rule with SwiftSyntax (#4156)
* Rewrite `large_tuple` rule with SwiftSyntax

* Add changelog, remove import

* Update Source/SwiftLintFramework/Rules/Metrics/LargeTupleRule.swift

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

Co-authored-by: JP Simard <jp@jpsim.com>
2022-09-05 01:10:59 -04:00
Marcelo Fabri 79347a1728
Rewrite ForceUnwrappingRule using SwiftSyntax (#4155) 2022-09-04 02:08:26 -07:00
Marcelo Fabri c1650e6918
Add `excludes_trivial_init` for `missing_docs (#4152)
Fixes #4107
2022-09-03 22:11:57 -07:00
JP Simard 57dc1c9532
release 0.49.1 2022-09-01 12:32:19 -04:00
JP Simard e0f23fa8e9
Add `--progress` flag to lint and analyze commands (#4147)
Inspired by https://github.com/jkandzi/Progress.swift

```
4948 of 29100 [=====                         ] ETA: 44s (540 files/s)
```

Demo:

[![asciicast](https://asciinema.org/a/517985.svg)](https://asciinema.org/a/517985)
2022-08-31 18:26:17 -04:00
JP Simard 4bc6588f38
Add `--output` option to lint and analyze commands (#4148)
To write to a file instead of to stdout.

Addresses https://github.com/realm/SwiftLint/issues/4048
2022-08-31 17:34:37 -04:00
JP Simard 9979c4fd27
Add new `self_binding` opt-in rule (#4146)
To enforce that `self` identifiers are consistently re-bound to a common
identifier name.

Configure `bind_identifier` to the name you want to use.

Defaults to `self`.

Addresses https://github.com/realm/SwiftLint/issues/2495
2022-08-30 16:37:19 -04:00
JP Simard f032c82b59
Fix link in comments (#4145) 2022-08-29 14:29:20 -04:00
Martin Hosna f32bc1f337
RedundantDiscardableLetRule should not produce warning when used with async (#4143)
handle situation with async let _ = ....
let can not be removed from "async let _ = ..." because removing it produces invalid swift syntax

Co-authored-by: Martin Hosna <mhosna@samepage.io>
2022-08-29 12:56:35 -04:00
JP Simard 4119c27857
Fix typo 2022-08-29 00:33:51 -04:00
JP Simard cd9bd5f9fd
Make duplicate_imports rule documentation deterministic (#4137) 2022-08-28 18:27:12 -04:00
Danny Mösch 9875ab904b
Print autocorrected STDIN input to STDOUT (#4132) 2022-08-28 23:17:20 +02:00
Danny Mösch bf9bf83143
Migrate EmptyXCTestMethodRule to SwiftSyntax fixing some false-positives (#4129) 2022-08-27 03:02:05 -04:00
JP Simard ef36201e6b
release 0.49.0 2022-08-26 10:48:09 -04:00
JP Simard 5a30991fa4
Add SwiftSyntax rule helpers (#4126)
This cuts down on the boilerplate involved in writing SwiftSyntax-based
rules. May not be significant right now since most rules are still built
with SourceKit, but as we migrate more rules moving forward, this should
make it easier for rule authors to write rules that behave performantly
and correctly.
2022-08-26 14:46:32 +00:00
Ben Davis 7dfadc205a
Add new configuration to `operator_usage_whitespace` rule to specify no-space operators (#4112) 2022-08-25 17:59:27 +02:00
JP Simard cf764e7b90
Fix hang after linting or analyzing on Linux (#4123)
Fixes https://github.com/realm/SwiftLint/issues/4117
2022-08-23 13:45:10 -04:00
JP Simard 83bf37e642
Add `SwiftLintFile.isTestFile` (#4122) 2022-08-23 12:04:30 -04:00
JP Simard 7259c02ee5
Teach `--compile-commands` to parse SwiftPM yaml files (#4119)
And move analyze CI job to Bazel

Which will benefit from caching previous results,
so if we make a PR that doesn't impact the analysis
results (i.e. changelog or docs) we might be able to
skip running this at all.
2022-08-23 11:01:13 -04:00
Danny Mösch f3e2c0b7bb
Replace manual backtracking by location information from the captured group (#4111) 2022-08-19 20:14:19 +02:00
Danny Mösch 6dc2ef937e
Add trigger markers to examples (#4110) 2022-08-18 22:15:11 +00:00
JP Simard dd55f59207
release 0.49.0-rc.2 2022-08-18 13:31:47 -04:00
Kotaro Suto 78949c1b99
Fix broken correction for `explicit_init` rule (#4109) 2022-08-18 17:17:52 +00:00
chrisjf 1ef15f3bb7
Update documentation for multiline_arguments_brackets and multiline_literal_brackets (#4098)
- added two triggering examples that are a common style, to make it immediately obvious that they trigger the rules
- also fixed a spelling mistake throughout the examples for the multiline_literal_brackets rule ("Gryffindor" is now correctly spelt)
2022-08-18 09:53:52 +02:00
Kotaro Suto 3aa249b8a1
Fix first_where false negative (#4105) 2022-08-17 00:06:32 +00:00
JP Simard c2be5b18b4
Only check `sourcekitdFailed` for SourceKit-based rules (#4104)
And only warn once if it's disabled.

This check is expensive and as more rules move away from SourceKit to
SwiftSyntax, it's increasingly common for rules to not use SourceKit at
all.

In addition, SourceKit crashes used to be a lot more common but I
haven't seen one myself in quite a while.
2022-08-16 16:46:55 +00:00
JP Simard 73c88c3af0
Add `version --verbose` command (#4102)
Prints out something like this on macOS:

```
Version: 0.49.0-rc.1
Build ID: B43931F3-D096-3704-B41C-FC40673A3F96
```

This can be used to determine if two `swiftlint` executables are
identical.
2022-08-16 14:12:44 +00:00
JP Simard ac23f2e89a
Log time spent in each custom rule (#4100) 2022-08-15 22:03:06 -04:00
JP Simard 13703c4466
Update SourceKitFreeRules (#4097)
None of these rules use SourceKit
2022-08-16 00:56:03 +00:00
JP Simard 3037946bbc
Migrate ClosureSpacingRule to SwiftSyntax (#4092)
Fixes #4090. Continued from #4091.
2022-08-15 18:27:43 +00:00
sarastro-nl d1a1485af6
enable glob for includePaths (#4093) 2022-08-15 13:54:49 +00:00
Danny Mösch ef515ac45e
Fix false positive in `yoda_condition` rule basing it on SwiftSyntax (#4089) 2022-08-14 16:30:09 -04:00
JP Simard 6f03036591
release 0.49.0-rc.1 2022-08-12 09:49:13 -04: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
Timofey Solonin 557c5b5948
Make `duplicate_imports` rule correctable (#4014)
Also fix reporting of redundant violations when more than one duplicate is present.
2022-08-11 18:19:26 +02:00
Danny Mösch a02d4a76cb
Remove references to ManuallyTestedExamplesRule protocol (#4082)
Follow-up of d730e0b3fa.
2022-08-10 21:42:10 +00:00
Danny Mösch d730e0b3fa
Let all example verification tests be generated by Sourcery (#4076) 2022-08-10 22:49:28 +02:00
Danny Mösch 828f36958f
Introduce option to ignore indentation of compiler directives in `indentation_width` rule (#4066) 2022-08-10 21:52:32 +02:00
Sara Tavares 436a6f3484
chore(typo): fix typo on func (#4077) 2022-08-10 13:35:42 -04:00
Danny Mösch 449190d324
Verify examples in rules by default and enforce explicit exclusion (#4065)
A rule must conform to ManuallyTestedExamplesRule to skip generation of a test for its examples.
2022-08-09 22:32:09 +02:00
JP Simard 1ac0419eb6
Fix failing Swift 5.7 test (#4075)
Seems like `CGPoint` moved from the `CoreGraphics` module to the
`CoreFoundation` module.
2022-08-09 16:44:05 +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