Commit Graph

1829 Commits

Author SHA1 Message Date
Ornithologist Coder 2039ee6b7b Improves 'let' keyword validation 2018-01-05 06:48:54 +01:00
Ornithologist Coder 1295c5d182 Adds opt-in prefixed_toplevel_constant rule
Implements #1907.
2018-01-05 04:07:10 +01:00
JP Simard 34d2fb3949 Move Configuration.defaultIndentation() to IndentationStyle init 2018-01-03 23:31:12 -08:00
JP Simard fa13551af1 Rename Configuration.Indentation to IndentationStyle
and move to its own file
2018-01-03 23:21:23 -08:00
JP Simard 5fd67018bb Fix comment alignment 2018-01-03 23:16:37 -08:00
Noah McCann fa5815e9f5 Extracted rule logic to separate function to address linting errors 2018-01-03 23:05:48 -08:00
Noah McCann ab29b75d20 Addressed most linting errors 2018-01-03 23:05:48 -08:00
Noah McCann 093367073a Renamed IndentationMode to Indentation, better handled default value 2018-01-03 23:05:48 -08:00
Noah McCann 38f869bf81 Added indentationMode to configuration, updated parsing to handle it 2018-01-03 23:05:48 -08:00
Ornithologist Coder a3c6a7f40c Adds opt-in discouraged_object_literal rule
Implements #1987.
2018-01-03 23:00:54 -08:00
JP Simard 5966896575 Fix missing word in comment 2018-01-03 21:42:55 -08:00
Donald Ritter 1deddf2334 Adds a new rule which allows for enums that conform to protocol to
require cases.
2017-12-22 13:08:51 -05:00
JP Simard 1541f519b2 Merge pull request #1966 from joseprl89/feature/explicit_acl_rule
Add explicit acl rule to satisfy Issue #1649
2017-12-22 12:51:48 -05:00
JP Simard a9b6a6f07e Fix false positives in unused_closure_parameter rule
when closure is wrapped in parentheses. Fixes #1979.

Definitely not elegant, but it should help.
2017-12-21 17:52:06 -05:00
JP Simard c7c77f55ea Merge pull request #1965 from dirtydanee/yoda-condition
Introduction of Yoda condition checking.
2017-12-20 15:18:54 -05:00
JP Simard a35e231417 Fix Linux compilation 2017-12-20 14:50:56 -05:00
JP Simard a973a89818 Refactor YodaConditionRule a bit 2017-12-20 14:44:54 -05:00
JP Simard f1a3374261 Add .repeatWhile to list of conditional statement kinds 2017-12-20 14:44:54 -05:00
JP Simard 47c47262ff Minor style fixes to YodaConditionRule 2017-12-20 14:44:54 -05:00
JP Simard 84a39a57a6 Replace use of YodaConditionConfiguration with SeverityConfiguration
since YodaConditionConfiguration had no additional configuration points
2017-12-20 14:44:54 -05:00
Marcelo Fabri c1da2bd194 Fix false positives in for_where with pattern matching
Fixes #1968
2017-12-20 11:23:05 -08:00
Daniel Metzing f8f9c0e7f1 Introduction of Yoda condition checking.
This PR aims to implement [#1924][1].
[1]: https://github.com/realm/SwiftLint/issues/1924
2017-12-18 15:42:13 +01:00
Marcelo Fabri 02792c1a01 Fix false positives in control_statement when methods with keyword names are used
Fixes #1946
2017-12-04 23:18:16 -08:00
Marcelo Fabri f01ed995c7 Merge pull request #1935 from ornithocoder/private_ibaction
Adds private_action opt-in rule
2017-12-04 22:49:08 -08:00
Josep Rodríguez e150e5b92f Add explicit acl rule to satisfy Issue #1649 2017-12-02 20:39:42 +00:00
JP Simard a02d4e17dd Small refactor in NimbleOperatorRule.swift 2017-11-30 11:05:45 -08:00
Ornithologist Coder 9d2c113ba8 Adds new opt-in rule, private_action
Implements #1931.
2017-11-17 18:13:48 +01:00
Norio Nomura 13768b70f6 Stop using numerical comparison in SwiftVersion 2017-11-16 11:53:29 +09:00
Norio Nomura d460c6d124 Invalidate cache when Swift patch version changes 2017-11-16 11:03:08 +09:00
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