Commit Graph

1800 Commits

Author SHA1 Message Date
JP Simard 06ece1ea8d release 0.24.0 2017-11-10 15:49:41 -08:00
JP Simard 93ded518a7 Remove uses of String.characters, deprecated in Swift 4.0.2 2017-11-10 14:37:53 -08:00
JP Simard 170ad413f0 Lock accesses to assert handler storage
This fixes races seen "in the wild" causing crashes.
2017-11-09 12:28:45 -08:00
JP Simard aa73566b39 Convert Cache struct to a class
to avoid having to lock calls to mutating functions that don't
actually perform mutating operations.

This fixes races seen "in the wild" causing crashes.
2017-11-09 12:28:45 -08:00
Tom Quist a2099abb9d Added changelog entry and added new triggering examples from firefox project 2017-11-08 07:02:34 +01:00
Tom Quist 9d75e39b3c * Added documentation for validate method in CallPairRule
* Made CallPairRule internal
* Fixed indentation of guard bodies
2017-11-07 08:41:40 +01:00
Tom Quist 7997192a70 Refactored ContainsOverFirstNotNilRule, FirstWhereRule and SortedFirstLastRule into new protocol CallPairRule to decrease code duplication 2017-11-07 00:23:10 +01:00
Tom Quist a71ef96467 Use confusing date format which seems to be preferred by SwiftLint 2017-11-06 21:22:55 +01:00
Tom Quist 630a676921 Added rule to prefer min/max over sorted.first and sorted.last 2017-11-06 21:10:53 +01:00
JP Simard 34f429b0a3 Fix caching on Linux
This has never worked for two reasons:

1. We've used dictionaries to represent cache descriptions, which
   don't guarantee stable ordering of keys across invocations.
   This is true both on Darwin and Linux, but in practice ordering
   varies significantly more on Linux.
2. Storing a `TimeInterval` value in a `[String: Any]` dictionary
   and retrieving it again will not be dynamically castable to
   `Double` or `TimeInterval` but will be castable to `Int`.
2017-10-26 12:23:13 -07:00
JP Simard 170606d3d9 Add more examples to SortedImportsRule 2017-10-23 15:27:30 -07:00
JP Simard ac53589f79 Fix issues with SortedImportsRule
* Fix superfluous disable command producing false positives
* Fix import formatting assumptions:
  * Exactly once space after `import`
  * No support for `@testable import`
* Reduce indentation
* Omit types when they can be inferred
* Omit explicit references to `self.`
* Fix typos in comments
* Make constrained extensions more generic
* Use explicit ACLs for all declarations
2017-10-23 15:27:30 -07:00
Samuel Susla 14036dca38 Make sorted_imports rule group imports into groups 2017-10-23 15:10:17 -07:00
Samuel Susla 708e73b0c8 Make sorted_imports corractable 2017-10-23 15:10:17 -07:00
Ornithologist Coder d387532929 Filters out parameters within parameters
For a function that takes a closure as default value, the array of
parameter reported by sourcekit also includes the parameters of that
closure.

In other words, a function like

func foo(param1: Int,
         param2: Bool,
         param3: (Int) -> Void = { (x: Int) in }) { }

reports 4 parameters (param 1, param2, param3, and x).

This commit uses the bounds of the method/function parameters to filter
out parameters within parameters. Below, a 1, a 2, and a 3 would be
filtered out since they're inside parameter 3.

----------------------------------------------------------------|
|        |---------| |---------| |----------------------------| |
|        | param 1 | | param 2 | | param 3: |a 1| |a 2| |a 3| | |
|        |---------| |---------| |----------------------------| |
----------------------------------------------------------------|
2017-10-21 10:58:10 +02:00
Ornithologist Coder f6dc900400 Adds more examples with closures 2017-10-21 10:58:10 +02:00
Ornithologist Coder d356fbb8cf Fix false positive in multiline_parameters rule
when parameter is a closure has default value. Fixes #1912.
2017-10-21 10:58:03 +02:00
JP Simard 95f40be8bc Add catch to the statements checked by the control_statement rule 2017-10-20 12:28:07 -07: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
JP Simard 08e0c816f3 Make Configuration conform to Hashable 2017-10-19 22:50:07 -07:00
JP Simard 757443d201 Correct and speed up equality checks for Configuration values
they previously didn't account for `warningThreshold` or `cachePath`.
2017-10-19 22:28:04 -07:00
JP Simard a49835728b Speed up equality checks for [Rule] values 2017-10-19 22:28:04 -07:00
Ornithologist Coder c1a63db729 Adds xitBehavesLike 2017-10-17 16:06:05 +02:00
Ornithologist Coder f84354f3e0 Fixes indentation 2017-10-17 15:48:14 +02:00
Ornithologist Coder c7e3692ddf Adds quick_discouraged_pending_test opt-in rule
Implements #1909.
2017-10-17 14:49:36 +02:00
JP Simard 234f987445 Merge pull request #1904 from ornithocoder/quick_calls
Adds [f,x]{describe, context, itBehavesLike} to quick_discouraged_call rule
2017-10-16 13:31:09 -07:00
Ornithologist Coder 98cc4e083e Moves examples to another file 2017-10-16 08:54:37 +02:00
Ornithologist Coder c4b0053ed0 Adds fitBehavesLike and xitBehavesLike 2017-10-16 06:48:56 +02:00
Ornithologist Coder d039434b5c Adds fitBehavesLike 2017-10-16 06:35:01 +02:00
Ornithologist Coder b12280cfc2 Adds opt-in quick_discouraged_focused_test rule
Implements #1905.
2017-10-15 23:14:35 +02:00
Ornithologist Coder 61e19ea47f Adds [f,x]{describe, context, it} to Quick Call rule
* fdescribe
* fcontext
* fi
* xdescribe
* xcontext
* xit

are valid Quick calls and should not trigger this violation.

There should be another SwiftLint rule to discourage the use of focused
tests, so people don't commit and push code with focused tests.
2017-10-15 16:31:06 +02:00
Marcelo Fabri a45a7da03f Make rule opt-in 2017-10-08 21:03:55 -03:00
Marcelo Fabri c384ec4f19 Don’t trigger violations for extensions in same file 2017-10-07 20:28:11 -03:00
Marcelo Fabri f971d4bc39 Add override_in_extension rule
Fixes #1884
2017-10-07 19:33:59 -03:00
Marcelo Fabri 96c6a13a92 Fix disabling superfluous_disable_command rule
Fixes #1890
2017-10-06 16:29:35 -03:00
Marcelo Fabri 881208aea3 Merge pull request #1883 from marcelofabri/sort-rule-identifiers
Sort list of rule identifiers before printing them
2017-10-05 16:52:16 -03:00
Marcelo Fabri e84100eed4 Remove SwiftExpressionKind.other 2017-10-05 14:33:32 -03:00
Marcelo Fabri d4f4f5f35c Sort list of rule identifiers before printing them 2017-10-05 11:51:36 -03:00
JP Simard 60ffa73253 Remove intermediate closure 2017-10-04 14:41:08 -07:00
Marcelo Fabri 0be8c855d2 Move functions to properties and Sets instead of Arrays 2017-10-04 14:34:00 -07:00
JP Simard c57c47d66f Remove unnecessary Swift version differences 2017-10-04 13:49:40 -07:00
Marcelo Fabri ee02e0f8e5 Remove support for building with Swift 3.1 2017-10-04 13:48:17 -07:00
Marcelo Fabri c585ee9568 Fix false positive in array_init when using map without closure
Fixes #1878
2017-10-04 01:24:16 -03:00
Marcelo Fabri d1cc128660 release 0.23.0 2017-10-03 21:55:00 -03:00
Marcelo Fabri aa88d5a707 Fix existing violations 2017-10-02 02:09:53 -03:00
Marcelo Fabri 81b832c372 Add literal_expression_end_indentation opt-in rule 2017-10-02 02:09:45 -03:00
Marcelo Fabri 192411f9c4 Add unneeded_break_in_switch rule
Fixes #1870
2017-10-02 00:21:27 -03:00
Marcelo Fabri 41f8b1971d Merge pull request #1862 from sirlantis/add-new-multiline-arguments-rule
Add MultilineArgumentsRule
2017-10-02 00:20:28 -03:00
Marcelo Fabri 44f3e3895c Merge pull request #1873 from marcelofabri/queuedFatalError-custom-rule
Add custom rule to enforce using queuedFatalError
2017-10-01 20:49:52 -03:00
JP Simard 508ab99c38 Merge pull request #1868 from atetlaw/at-fix-csv-reporter
Fix csv reporter to output records with new lines
2017-10-01 16:06:46 -07:00