You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
line_length: ignores_urls strips property accesses like post.id (NSDataDetector matches bare domains with valid TLDs) #6811
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
$ cat Repro.swift
// Both lines are exactly 124 characters long. Only the second one is reported.
guardletresponse=try?awaitqoqaService2.performRequest(GetUserBookmarkRequest(postId:post.id))else{return}guardletresponse=try?awaitqoqaService2.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:
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 /.
A table-driven regression test could cover property accesses whose suffix is both a real TLD and a non-TLD, such as post.id versus post.identifier, inside code, comments, and string literals. It may also be worth including chained access like response.post.id so a fix does not merely inspect the first token before the dot. The expected behavior for genuinely schemeless URLs such as example.com/path should remain explicit.
Activity
hiSandog commentedon Jul 11, 2026
A table-driven regression test could cover property accesses whose suffix is both a real TLD and a non-TLD, such as
post.idversuspost.identifier, inside code, comments, and string literals. It may also be worth including chained access likeresponse.post.idso a fix does not merely inspect the first token before the dot. The expected behavior for genuinely schemeless URLs such asexample.com/pathshould remain explicit.