Swiftlint: function_parameter_count should ignore initializers

Created on 16 Feb 2016  路  5Comments  路  Source: realm/SwiftLint

How would you work around models with a good amount of properties to be set on an initializer?
I agree with the number of parameters being limited, but not initializers themselves.

screen shot 2016-02-16 at 18 54 25

enhancement

Most helpful comment

I tried applying your fix to the FunctionParameterCountRule but I'm still seeing the warning with my project. The issue seems to be that my constructor is being recognized as FunctionMethodInstance instead of FunctionConstructor. :(

All 5 comments

Just // swiftlint:disable:next function_parameter_count on the line above the initializer?

It's not about working around but rather trying to understand why it's a best practice when it comes to initializers.

Ok, thinking about this more I would agree. This was even suggested in the initial issue tracking this rule (https://github.com/realm/SwiftLint/issues/415#issue-128552879). This should be just a matter of removing FunctionConstructor from the functionKinds used to apply the rule: https://github.com/realm/SwiftLint/blob/0.9.0/Source/SwiftLintFramework/Rules/FunctionParameterCountRule.swift#L101

I tried applying your fix to the FunctionParameterCountRule but I'm still seeing the warning with my project. The issue seems to be that my constructor is being recognized as FunctionMethodInstance instead of FunctionConstructor. :(

Was this page helpful?
0 / 5 - 0 ratings