Commit Graph

4 Commits

Author SHA1 Message Date
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
Ornithologist Coder 48bb6c77d4 Adds multiline method definition rule
Parameters of methods and functions should be either on the same line,
or one per line.
2017-05-26 14:54:01 +02:00