New Issue Checklist
Bug Report
line_length with ignores_urls: true silently skips lines containing ordinary property accesses like post.id or user.name, because NSDataDetector recognizes them as links (.id, .name, .info, … are valid TLDs).
Complete output when running SwiftLint, including the stack trace and command used
// Both lines are exactly 124 characters long. Only the second one is reported.
guard let response = try? await qoqaService2.performRequest(GetUserBookmarkRequest(postId: post.id)) else { return }
guard let response = try? await qoqaService2.performRequest(GetUserBookmarkRequest(postId: postXid)) else { return }
$ cat .swiftlint.yml
line_length:
ignores_urls: true
$ swiftlint lint --no-cache Repro.swift
Repro.swift:3:1: warning: Line Length Violation: Line should be 120 characters or less; currently it has 124 characters (line_length)
Line 2 (post.id) produces no violation; line 3 (postXid), identical in length, is flagged.
Environment
- SwiftLint version: 0.65.0
- Xcode version: 26.x
- Installation method used: Homebrew
- Configuration file: see above (
ignores_urls: true is the only relevant option)
Root cause
String.strippingURLs in LineLengthRule.swift uses NSDataDetector(types: .link) and removes every match before measuring the line:
https://github.com/realm/SwiftLint/blob/main/Source/SwiftLintBuiltInRules/Rules/Metrics/LineLengthRule.swift
NSDataDetector intentionally matches bare domains such as example.com — but in Swift source, member accesses like post.id, user.name or offer.info have the same shape (identifier.validTLD), so they are stripped too. In a codebase using ignores_urls: true, any over-long line that happens to contain such an expression passes the rule.
Possible fix
Only strip matches that look like actual URLs, e.g. require a scheme (match.url?.scheme != nil and not the implicit http NSDataDetector adds to bare domains), or require the match to contain :// / start with www.. The Linux regex path already roughly does this by requiring a scheme, www., or a trailing /.
New Issue Checklist
Bug Report
line_lengthwithignores_urls: truesilently skips lines containing ordinary property accesses likepost.idoruser.name, becauseNSDataDetectorrecognizes them as links (.id,.name,.info, … are valid TLDs).Complete output when running SwiftLint, including the stack trace and command used
// Both lines are exactly 124 characters long. Only the second one is reported. guard let response = try? await qoqaService2.performRequest(GetUserBookmarkRequest(postId: post.id)) else { return } guard let response = try? await qoqaService2.performRequest(GetUserBookmarkRequest(postId: postXid)) else { return }Line 2 (
post.id) produces no violation; line 3 (postXid), identical in length, is flagged.Environment
ignores_urls: trueis the only relevant option)Root cause
String.strippingURLsinLineLengthRule.swiftusesNSDataDetector(types: .link)and removes every match before measuring the line:https://github.com/realm/SwiftLint/blob/main/Source/SwiftLintBuiltInRules/Rules/Metrics/LineLengthRule.swift
NSDataDetectorintentionally matches bare domains such asexample.com— but in Swift source, member accesses likepost.id,user.nameoroffer.infohave the same shape (identifier.validTLD), so they are stripped too. In a codebase usingignores_urls: true, any over-long line that happens to contain such an expression passes the rule.Possible fix
Only strip matches that look like actual URLs, e.g. require a scheme (
match.url?.scheme != niland not the implicithttpNSDataDetector adds to bare domains), or require the match to contain:/// start withwww.. The Linux regex path already roughly does this by requiring a scheme,www., or a trailing/.