Commit Graph

43 Commits

Author SHA1 Message Date
Marcelo Fabri 804e8d69a0 Lauch plugin process from SwiftLint when linting 2018-12-28 00:22:02 -08:00
JP Simard 2bcea4b04d
Add ability for SwiftLint to lint files with full type-checked AST awareness (#2379)
* Add LintableFilesVisitor

* Move LintCommand logic into LintOrAnalyzeCommand

to prepare for the upcoming analyze command

* Add AnalyzeCommand (not fully implemented yet in SwiftLintFramework)

* Add analyzerRules configuration member

* Add AnalyzerRule protocol

* Pass compiler arguments to validate/correct

* Add requiresFileOnDisk member to RuleDescription

This will be used by AnalyzerRules because they need a file on disk
to pass in the compiler arguments to SourceKit.

* Exclusively run AnalyzerRules when the Linter has compiler arguments

* Enable testing AnalyzerRules in TestHelpers

* Add ExplicitSelfRule

* Update documentation

* Fix `analyze --autocorrect`

* Improve performance of CompilerArgumentsExtractor

* Fix lint command actually running analyze

* Move File operations in TestHelpers into a private extension

* Add analyzer column to rules command and markdown documentation

* Use a Set literal

* Make AnalyzerRule inherit from OptInRule

* Mention analyzer_rules in readme

* Mention that analyzer rules are slow
2018-09-02 00:13:27 -07:00
Ben Asher 7a32b8d4c2 Support for multiple paths 2018-07-23 10:13:55 -07:00
JP Simard b83e0991b9
Remove all file headers
The MIT license doesn't require that all files be prepended with this
licensing or copyright information. Realm confirmed that they're ok with this
change. This will enable some companies to contribute to SwiftLint and the
date & authorship information will remain accessible via git source control.
2018-05-04 13:42:02 -07:00
Norio Nomura 2a0ac455bc
'flatMap' is deprecated: renamed to 'compactMap(_:)' 2018-04-08 13:28:09 +09:00
Ash Furrow 63658418c4 Adds unit test for force-exclude flag. 2018-03-22 09:42:56 -07:00
Ash Furrow 7ed962d1ee Adds force-exclusion config. 2018-03-22 09:42:56 -07:00
JP Simard b2227accc3
Avoid calling `cacheDescription` when the cache is disabled
This skips an expensive JSON serialization call.
2017-11-09 12:28:45 -08:00
JP Simard 3a32d6b479
Speed up reading cached results by about 200%
also slightly speed up writing to the cache.

For example, on the Lyft codebase with 1,500 Swift files:

```bash
$ time swiftlint lint --quiet
swiftlint --quiet  3.53s user 0.27s system 388% cpu 0.979 total
$ rm -rf ~/Library/Caches/SwiftLint && time swiftlint lint --quiet
swiftlint --quiet  35.20s user 1.22s system 371% cpu 9.806 total
$ time swiftlint lint --quiet
swiftlint lint --quiet  0.90s user 0.13s system 218% cpu 0.472 total
$ rm -rf ~/Library/Caches/SwiftLint && time swiftlint lint --quiet
swiftlint lint --quiet  31.78s user 1.18s system 360% cpu 9.146 total
```
2017-10-19 23:17:01 -07:00
Marcelo Fabri 68c1f3c1ab Fix configuration issue when using custom paths
Fixes #1631
2017-06-24 22:54:10 +02:00
Marcelo Fabri 33955234b3 Skip files with valid cache & no violations when auto correcting 2017-05-28 12:47:52 +02:00
JP Simard 97bdac211a
keep a single cache file for all of SwiftLint 2017-05-18 14:45:46 -07:00
JP Simard 9b51973961
actualy pass enableAllRules value to Configuration initializer 2017-01-12 14:13:48 -08:00
Marcelo Fabri b7b905c3e5 Merge branch 'master' into cache 2017-01-10 14:33:04 -02:00
JP Simard 9db40bf3e1
update swiftlint/Extensions to follow Swift 3 API Design Guidelines 2017-01-10 08:00:17 -08:00
Marcelo Fabri e1e2369c5f Merge branch 'master' into cache 2017-01-10 12:54:30 -02:00
JP Simard c5c2e21120
update SwiftLintFramework/Models to follow Swift 3 API Design Guidelines 2017-01-09 19:05:29 -08:00
Marcelo Fabri 119c214492 Merge remote-tracking branch 'upstream/master' into cache 2017-01-02 16:29:32 -02:00
JP Simard 3608cf4675
re-add autoreleasepool around visitorBlock invocation 2017-01-01 10:50:10 -08:00
JP Simard 8774a921a6
use DispatchQueue.concurrentPerform rather than rolling our own
also remove parallelForEach from SwiftLintFramework's public interface
since calling the GCD API is almost as concise and avoids polluting the
public API.

Finally, also remove the "fast" path for parallelMap since GCD should
do the reasonable thing for us here.
2016-12-31 17:06:02 -08:00
JP Simard f24ceac200
parallelize linting multiple files 2016-12-30 23:09:07 -08:00
Marcelo Fabri a2ea9ca2a4 Merge remote-tracking branch 'upstream/master' into cache
# Conflicts:
#	Source/swiftlint/Commands/LintCommand.swift
2016-12-31 01:33:08 -02:00
Marcelo Fabri b006a28f00 Merge remote-tracking branch 'upstream/master' into cache
# Conflicts:
#	Source/swiftlint/Commands/LintCommand.swift
#	Source/swiftlint/Extensions/Configuration+CommandLine.swift
#	SwiftLint.xcodeproj/project.pbxproj
2016-12-31 01:17:16 -02:00
JP Simard 86308adf6b
refactor LintCommand
mostly by moving things out of run(_:) and out of the file
2016-12-30 18:43:51 -08:00
Marcelo Fabri 3d376241be Moving cache usage to the linter 2016-12-31 00:26:05 -02:00
JP Simard 3106f32649
move autoreleasepool invocation into visitLintableFiles
which cleans up the call site a bit and brings the memory footprint
improvements to AutoCorrectCommand too.
2016-12-30 18:21:11 -08:00
Marcelo Fabri 1351fdb643 Fix violations for void_return rule 2016-12-13 10:41:08 -02:00
JP Simard 0faf567931
use bridge() rather than explict or implicit casts
this is a step in aligning the code to compile on both Darwin and
Linux
2016-12-11 13:47:44 -08:00
JP Simard fe01334bb3
another small refactoring of Configuration+CommandLine.swift 2016-12-08 01:39:41 -08:00
JP Simard 27d999414c
minor refactoring of Configuration+CommandLine.swift 2016-12-08 01:35:19 -08:00
Norio Nomura 8bf15f1dba
Migrate to Swift 3.0 2016-10-09 01:09:50 +09:00
JP Simard c66c5c8df0 formatting fixes
found running `swiftlint autocorrect --format`
2016-05-29 14:58:28 -07:00
JP Simard 048c5dda84 expand "config" to "configuration" in Configuration.swift
with an exception being made for the "use_nested_configs" configuration key,
since that's already long enough as it is
2016-02-12 10:53:36 -08:00
JP Simard 59da7f3ce9 add `--quiet` flag to `lint` and `autocorrect` commands
addresses #386
2016-02-08 13:21:40 -08:00
Scott Hoyt 9188d161f5 Added recursive search for configurations. 2016-01-02 15:41:53 -08:00
JP Simard b653973776 re-introduce use-script-input-files option for lint & autocorrect 2015-12-13 16:59:01 -08:00
JP Simard 8ab6f4674a clarify that stdin must be a UTF8-encoded string 2015-12-05 20:52:40 -08:00
JP Simard 0ca4221161 move Configuration.lintableFilesForPath out of extension and into framework 2015-12-05 20:49:49 -08:00
JP Simard 341406a90c add Configuration.visitLintableFiles
to simplify performing operations on all files (e.g. autocorrect)
2015-12-05 20:49:49 -08:00
JP Simard 491e0a7db7 add Configuration.getFiles to combine STDIN, input files & standard behaviors 2015-12-05 20:44:00 -08:00
JP Simard a17bc283d9 move scriptInputFiles() to Configuration+CommandLine.swift 2015-12-05 20:44:00 -08:00
JP Simard 8f534df33d add Configuration.lintableFilesForPath(...) 2015-12-05 20:44:00 -08:00
JP Simard c708c53fc1 introduce Configuration+CommandLine.swift and move initialization to it 2015-12-05 20:44:00 -08:00