Commit Graph

440 Commits

Author SHA1 Message Date
Vladimir 3a6503212d Set the excluded files list once when getting lint files (#5330) 2023-11-10 15:04:07 -05:00
Marcelo Fabri 686dc3dd32 Rewrite RedundantVoidReturnRule with SwiftSyntax (#4192)
Also include redundant void return clauses for closures in addition to
functions. This can be disabled by configuring the rule with
`include_closures: false`.

Co-authored-by: JP Simard <jp@jpsim.com>
2023-10-30 13:41:31 -04:00
Danny Mösch 58928b7e40 Enforce any on existential types (#5273)
This makes syntactically clear which types are rather expensive.
2023-10-12 08:37:23 +02:00
JP Simard 406d4d270b Require Swift 5.9 (#5235)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2023-09-25 18:54:02 -04:00
Martin Redington f783b0279a Add strict configuration file setting (#5226) 2023-09-18 19:27:30 +02:00
Danny Mösch 8b2778e380 Add --config-only and --default-config options to rules command (#5199) 2023-09-02 05:41:23 -04:00
Danny Mösch 668cce84db Print YAML configuration in output of rules command 2023-08-28 20:19:28 +02:00
Danny Mösch a25fbe3e50 Make indent function a String extension 2023-07-17 23:18:26 +02:00
Danny Mösch 678cd6f805 Introduce a model for rule configuration description (#3931) 2023-07-03 22:47:30 +02:00
Danny Mösch 41b06629fd Add new --silence-deprecation-warnings flag (#5014) 2023-06-20 16:03:22 -04:00
Danny Mösch fe312a06fe Rely on pre-defined issues and allow to print them directly to the console (#5013)
Advantages of having typical errors at a common place:
* Error message styling can be harmonized
* Existing messages can be reused
* Overview of prefixes ('error: ', 'warning: ')
* Manage how to print them to the console
2023-05-16 20:15:14 +02:00
Danny Mösch 1fa8e484c4 Add expiring TODO comments on deprecation warnings 2023-05-10 21:44:20 +02:00
Andyy Hope 5e15039554 Move excludedPaths out of iteration loop to speed up lint times (#4955) 2023-05-06 16:43:33 -04:00
Chris White 71b89e66de Prepend warning: to error messages (#4927) 2023-05-01 18:26:25 +02:00
JP Simard b2a4c9fcb9 Mark RulesFilter as final class (#4939)
Since it's not designed to be subclassed.
2023-04-26 16:26:22 +00:00
JP Simard 603fff9a82 Make Correction and CorrectableRule declarations public (#4937)
The CLI target shouldn't be importing SwiftLintFramework with
`@_spi(TestHelper)`. If the CLI target needs to access something in
SwiftLintFramework, that declaration should be `public`.
2023-04-26 12:17:10 -04:00
JP Simard 165172e0fa Introduce a "rule registry" concept
This will allow for registering rules that aren't compiled as part of
SwiftLintFramework.

Specifically this will allow us to split the built-in and extra rules
into separate modules, leading to faster incremental compilation when
working on rules since the rest of the framework won't need to be
rebuilt on every compilation.
2023-04-25 12:28:50 -04:00
Martin Redington 7dad240ea7 Add a reporters subcommand (#4836) 2023-03-31 08:09:01 +02:00
Martin Redington 31510b662e Use all optin rules facility for SwiftLint's own .swiftlint.yml (#4800) 2023-03-11 11:59:05 +01:00
Danny Mösch aafc574e90 Allow to pass a rule identifier to the swiftlint docs command (#4710) 2023-02-07 00:01:52 +01:00
Danny Mösch 325d0ee1e4 Consider custom attributes in attributes rule (#4616) 2023-01-31 22:34:11 +01:00
Danny Mösch 5eed8fe91b Enable if_let_shadowing rule and fix all violations (#4247) 2023-01-31 22:31:38 +01:00
Danny Mösch 500f143c7d Remove unused code (#4729) 2023-01-28 19:50:22 +01:00
JP Simard 84c6d200b6 Clean up unused initializers (#4726)
Found with the upcoming improve dead code detection.
2023-01-27 16:31:56 -05:00
Danny Mösch e64e82d80d Get rid of periods finishing rule descriptions 2023-01-10 22:29:13 +01:00
Ryan Aveo 92304cdd98 Fix building tests in Xcode (#4607)
Co-authored-by: JP Simard <jp@jpsim.com>
2022-11-30 10:33:33 -05:00
JP Simard ba8899714d Reduce visibility of custom rules (#4553) 2022-11-16 16:14:50 -05:00
Danny Mösch 1edef5ebdc Trigger prefer_self_in_static_references rule on constructor calls (#4519) 2022-11-06 14:55:28 +01:00
Danny Mösch 32152646f3 Use Self in constructor calls (#4505) 2022-11-02 22:50:22 +00:00
César Pinto Castillo c56e19a0c2 Fix SwiftLint support on Xcode Cloud (#4485)
Fixes #4484 by checking the process environment for all the expected
environment variables set by Xcode Cloud.
2022-11-01 13:00:50 -04:00
JP Simard 359699cea7 Report memory usage when --benchmark is specified (#4442)
With the memory increase related to
https://github.com/apple/swift-syntax/issues/921,
I wanted a way to quickly know how much memory was being used by
SwiftLint.

Here's how much memory it took to lint SwiftLint itself at various
versions in the last few weeks:

* 0.49.1: 223 MB
* 0.50.0-rc.1: 356 MB
* 0.50.0-rc.2: 444 MB
* main (458916174): 464 MB

```console
$ swiftlint --progress --benchmark
Linting Swift files in current working directory
529 of 529 [==============================] ETA: 0s (121 files/s)
Done linting! Found 0 violations, 0 serious in 529 files.
Memory used: 464 MB
$ swiftlint --progress --benchmark
Linting Swift files in current working directory
529 of 529 [==============================] ETA: 0s (16220 files/s)
Done linting! Found 0 violations, 0 serious in 529 files.
Memory used: 55.8 MB
```
2022-10-21 19:04:43 +00:00
JP Simard de0b91cd5a Print violations in realtime if progress with an output file (#4362) 2022-10-13 06:23:24 +00:00
Danny Mösch 9db88947b9 Fix bugs when auto-correcting content given via stdin (#4212)
Fixes #4211.
Fixes #4234.
Fixes #4347.
2022-10-13 00:34:48 -04:00
JP Simard 0f9705901b Add column for SourceKit usage to rules command (#4284) 2022-10-04 18:52:03 +00: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 4fb5ebe19b Docker: Update to Swift 5.7 & Ubuntu Jammy (#4241)
And apply workaround for https://github.com/apple/swift/issues/59961 to
all commands.
2022-09-24 15:09:41 -04:00
Danny Mösch 95ffaed655 Filter out compiler argument not understood by SourceKit in Xcode 14 (#4210) 2022-09-20 23:24:40 +02: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
Danny Mösch 9875ab904b Print autocorrected STDIN input to STDOUT (#4132) 2022-08-28 23:17:20 +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 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
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 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 ec8ba17388 Use @main attribute (#4072)
This will allow us to have an async entrypoint and use structured
concurrency features in the future.
2022-08-09 03:48:12 +00:00
JP Simard 2b00164081 Remove uses of Result in CLI target (#4071)
Which will make it easier to adopt some structured concurrency features
in the future.
2022-08-08 23:04:20 -04:00
JP Simard f39323160c Remove availability check (#4070)
Since SwiftLint now requires macOS 12 or higher to run.
2022-08-09 02:28:32 +00:00
JP Simard 24735ef4d3 Add support for building with Bazel (#4038) 2022-07-26 07:09:02 -04:00