Skip to content

Regression: line_length option ignores_function_declarations no longer applies to initializers #6241

@mattrubin

Description

@mattrubin

New Issue Checklist

Bug Description

Previously, with SwiftLint 0.59.1, this code does not trigger a line_length warning when ignores_function_declarations: true:

public class FileDataStore {
    public init(persistenceService: PersistenceService, syncService: SyncService, notificationService: NotificationService) throws {
        // ...
    }

    public func doSomething(persistenceService: PersistenceService, syncService: SyncService, notificationService: NotificationService) throws {
        // ...
    }
}
$ swiftlint Modules/Sources/Stores/DataStore/FileDataStore/FileDataStore.swift
Linting Swift files at paths Modules/Sources/Stores/DataStore/FileDataStore/FileDataStore.swift
Linting 'FileDataStore.swift' (1/1)
Done linting! Found 0 violations, 0 serious in 1 file.

After upgrading to SwiftLint 0.61.0, the line_length rule (still with ignores_function_declarations: true) now warns about a violation on the public init line, but not on the public func line.

$ swiftlint Modules/Sources/Stores/DataStore/FileDataStore/FileDataStore.swift
Linting Swift files at paths Modules/Sources/Stores/DataStore/FileDataStore/FileDataStore.swift
Linting 'FileDataStore.swift' (1/1)
/[…]/Modules/Sources/Stores/DataStore/FileDataStore/FileDataStore.swift:2:1: warning: Line Length Violation: Line should be 120 characters or less; currently it has 132 characters (line_length)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

  • SwiftLint version (run swiftlint version to be sure): 0.61.0
  • Xcode version (run xcodebuild -version to be sure): Xcode 16.4 (Build version 16F6)
  • Installation method used (Homebrew, CocoaPods, building from source, etc): Homebrew
  • Configuration file:
only_rules:
  - line_length

line_length:
  ignores_function_declarations: true

Are you using nested configurations? No

Metadata

Metadata

Assignees

Labels

bugUnexpected and reproducible misbehavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions