multiline_parameters false positive when closures have default values #1912
Closed
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
Bug Report
When there is a default parameter for a closure, linting fails.
Complete output when running SwiftLint, including the stack trace and command used
$ echo "func function(\nparam1: Int,\nparam2: @escaping (Int, Int) -> Void = { _, _ in }\n) {\n}" | swiftlint lint --use-stdin
Loading configuration from '.swiftlint.yml'
<nopath>:1:6: warning: Multiline Parameters Violation: Functions and methods parameters should be either on the same line, or one per line. (multiline_parameters)
Done linting! Found 1 violation, 0 serious in 1 file.
Environment
- SwiftLint version (run
swiftlint version
to be sure)? 0.23.1 - Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew or CocoaPods, happens on both
- Paste your configuration file:
disabled_rules:
- closing_brace
- cyclomatic_complexity
- force_cast
- force_try
- identifier_name
- line_length
- nesting
- notification_center_detachment
- todo
- trailing_comma
- trailing_whitespace
- type_name
- weak_delegate
- file_length
excluded:
- Carthage
- Pods
colon:
flexible_right_spacing: true
line_length: 400
type_body_length:
- 2048
- 2048
function_body_length:
- 400
- 400
force_try:
severity: warning
reporter: "xcode"
large_tuple:
- 4
- 4
opt_in_rules:
- closure_end_indentation
- closure_spacing
- empty_count
- explicit_init
- fatal_error_message
- first_where
- joined_default_parameter
- multiline_parameters
- overridden_super_call
- prohibited_super_call
- vertical_parameter_alignment_on_call
- Which Xcode version are you using (check
xcode-select -p
)? 9.0
// This triggers a violation:
func function(
param1: Int,
param2: @escaping (Int, Int) -> Void = { _, _ in }
) {
}
func function(
param1: Int,
param2: @escaping (Int) -> Void = { _ in }
) {
}