Swiftlint: multiline_function_chains triggers when it shouldn't

Created on 19 Nov 2018  路  2Comments  路  Source: realm/SwiftLint

New Issue Checklist

Describe the bug

The behaviour of the rule validation is either defined wrong or undefined for the situation when functions are chained without line breaking, whereas arguments in some functions have line breaks.
For example:

object.func1(arg1: value1,
                     arg2: value2).func2()

will generate a warning, whilst it shouldn't, in my opinion.

Environment

  • SwiftLint version: 0.28.1
  • Installation method used: Homebrew and CocoaPods?
  • Paste your configuration file:
disabled_rules:
  - type_name
  - identifier_name
  - nesting
  - file_length
  - cyclomatic_complexity
  - weak_delegate
  - leading_whitespace
  - multiple_closures_with_trailing_closure
opt_in_rules:
  - contains_over_first_not_nil
  - empty_count
  - first_where
  - vertical_parameter_alignment_on_call
  - overridden_super_call
  - operator_usage_whitespace
  - array_init
  - closure_spacing
  - anyobject_protocol
  - empty_xctest_method
  - explicit_init
  - fatal_error_message
  - identical_operands
  - legacy_random
  - let_var_whitespace
  - redundant_nil_coalescing
  - static_operator
  - unused_private_declaration
  - yoda_condition
  - redundant_type_annotation
  - multiline_function_chains
  - modifier_order
  - multiline_arguments
  - multiline_parameters

line_length: 200

  • Which Xcode version are you using: Version 10.1 (10B61)?
bug wontfix

Most helpful comment

I'm seeing the same issue with:

  • Xcode 10.1
  • Swiftlint 0.30.1

Triggering example:

    private func enlargedFrame(_ view: UIView, padding: CGFloat = 10.0) -> CGRect {
        return CGRect(
            x: view.frame.origin.x - padding,
            y: view.frame.origin.y - padding,
            width: view.frame.size.width + (padding * 2),
            height: view.frame.size.height + (padding * 2)
        )
    }

All 2 comments

I'm seeing the same issue with:

  • Xcode 10.1
  • Swiftlint 0.30.1

Triggering example:

    private func enlargedFrame(_ view: UIView, padding: CGFloat = 10.0) -> CGRect {
        return CGRect(
            x: view.frame.origin.x - padding,
            y: view.frame.origin.y - padding,
            width: view.frame.size.width + (padding * 2),
            height: view.frame.size.height + (padding * 2)
        )
    }

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

larslockefeer picture larslockefeer  路  3Comments

mildm8nnered picture mildm8nnered  路  3Comments

BalestraPatrick picture BalestraPatrick  路  3Comments

rajohns08 picture rajohns08  路  3Comments

ziryanov picture ziryanov  路  3Comments