Commit Graph

410 Commits

Author SHA1 Message Date
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
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 86e765c418
Deprecate the `--path` option in favor of the positional `paths` argument (#3952)
There is no real benefit for this option. Files and folders to lint/analyze
can be passed to `swiftlint` as last arguments. There cannot be multiple
`--path` arguments. If there is more than one only the last path is considered.
2022-06-14 23:10:28 +02:00
Marcelo Fabri 4382ef49b9
Use URL(fileURLWithPath:isDirectory) to avoid file system call (#3976) 2022-05-26 21:54:23 +02:00
Danny Mösch 291b500269
Analyze all files listed in the command even if the `--path` option is used (#3951) 2022-04-15 10:36:29 -04:00
coffmark 564c6ddb55
Lint all files listed in the command even if the `--path` option is used (#3923) 2022-04-13 15:13:08 -04:00
JP Simard e92a3aeae9
fixup! fixup! Add `--in-process-sourcekit` command line flag 2022-03-31 12:49:12 -04:00
JP Simard 4c14678d77
fixup! Add `--in-process-sourcekit` command line flag 2022-03-31 11:42:42 -04:00
Juozas Valančius 62cc0f1a32
Add `--in-process-sourcekit` command line flag 2022-03-31 09:46:21 -04:00
JP Simard 89ebac11d5
Fix analyzer rules with Xcode 13.3 (#3921)
* Fix analyzer rules with Xcode 13.3

Looks like starting with Xcode 13.3 / Swift 5.6, cursor info requests
started canceling in-flight requests, so we need to pass
`key.cancel_on_subsequent_request: false` to bypass that.

Analyzer rules on Swift 5.6 are extremely slow, however. Not really
usable right now.

* Run analyzer rules one file at a time

* Add changelog entry
2022-03-28 11:58:34 -04:00
Paul Taykalo b519753fd6
Speedup analyzer rules (#3747) 2021-10-18 08:40:15 -07:00
Adam Wolf 6953fe268e
Fix improper handling of `\ ` in Xcode build logs 2021-09-01 17:08:29 -04:00
JP Simard 60ec029e1b
Re-add --format flag to reformat Swift files using SourceKit (#3573)
Missed during the migration from Commandant to swift-argument-parser in
https://github.com/realm/SwiftLint/pull/3465.

Fixes https://github.com/realm/SwiftLint/issues/3571.
2021-03-15 11:15:09 -04:00
JP Simard eec4c58e1f
Fix parsing xcode logs for analyzer rules for target names with spaces 2021-03-03 10:36:22 -05:00
JP Simard 706abfe9e3
Tweak the auto-correction result console output for clarity (#3522)
A colleague was confused by the output of `swiftlint autocorrect`, she
couldn't understand why SwiftLint told her it corrected thousands of
files when she only touched one.

The "Done correcting \(files.count) ..." output made her think that a
change was made on each of the `files`, when really they had only been
inspected.

A good solution would be to adopt a similar approach as the `lint`
command does.

Not being familiar with the codebase, I though a good first step could
have been to tweak the message a bit, making it clearer that the count
printed to the console is the inspected files.
2021-02-25 17:20:58 -05:00
JP Simard 559470a245
Integrate OS Signposts to help profile SwiftLint performance (#3535)
* Integrate OS Signposts to help profile SwiftLint performance

* Split LintOrAnalyzeCommand.lintOrAnalyze(_:) into two functions

Using a builder reference type to share common mutable state.
2021-02-24 10:03:53 -08:00
Gio Lodi 8248178213
Tweak the auto-correction result console output for clarity
A colleague was confused by the output of `swiftlint autocorrect`, she
couldn't understand why SwiftLint told her it corrected thousands of
files when she only touched one.

The "Done correcting \(files.count) ..." output made her think that a
change was made on each of the `files`, when really they had only been
inspected.

A good solution would be to adopt a similar approach as the `lint`
command does.

Not being familiar with the codebase, I though a good first step could
have been to tweak the message a bit, making it clearer that the count
printed to the console is the inspected files.
2021-02-16 20:41:04 +11:00
Colton Schlosser 01a0f82e99
Improve parallelMap implementation by removing iteration for force unwrapping every element (#3517) 2021-02-08 06:37:20 -05:00
JP Simard 6de5771899
[Analyze] Support compile commands with relative paths (#3501)
* [Analyze] Support compile commands with relative paths

* Add changelog entry

And made small formatting edits to other recent entries.
2021-01-22 09:44:30 -08:00
JP Simard 5134545093
Make `--strict` mutually exclusive with `--lenient` 2020-12-14 15:54:08 -05:00
JP Simard 7351648590
Fix paths argument handling 2020-12-14 15:53:50 -05:00
JP Simard 6bad2eccdf
Remove unused imports 2020-12-14 15:53:49 -05:00
JP Simard fa55508668
Migrate from Commandant to swift-argument-parser 2020-12-14 15:51:04 -05:00
JP Simard 82b00bf4b5
Rename command files 2020-12-14 15:51:04 -05:00
JP Simard f926cfaabd
fixup! fixup! Fix logging linting the current working directory 2020-12-01 14:47:25 -05:00
JP Simard 0019c61de7
fixup! Fix logging linting the current working directory 2020-12-01 14:46:46 -05:00
JP Simard b73673ab01
Fix logging linting the current working directory
Fixes log messages saying `Linting files at path ''` that should have
said `Linting files in current working directory`.
2020-12-01 14:34:16 -05:00
JP Simard f0f0086aca
Merge pull request #3443 from realm/remove-info.plist-files
Remove Info.plist files
2020-11-23 10:47:36 -05:00
Frederick Pietschmann 4c5a3f0577 Add remote, parent & child configuration features 2020-11-20 23:08:37 +01:00
JP Simard e143a18e5c
Remove Info.plist files
These are no longer needed now that we removed the Xcode project.
2020-11-20 15:01:09 -05:00
JP Simard 8bf8ca482a
Fix deprecation compiler warnings on Linux for ShowDocsCommand.swift 2020-11-20 15:00:54 -05:00