Repository navigation
Add orphaned_doc_comment rule - #3014
Conversation
de89ae8 to
33dde02
Compare
jpsim
left a comment
There was a problem hiding this comment.
Awesome! 💯
Just have one question.
|
|
||
| public func validate(file: SwiftLintFile) -> [StyleViolation] { | ||
| let docStringsTokens = file.syntaxMap.tokens.filter { token in | ||
| return token.kind == .docComment || token.kind == .docCommentField |
There was a problem hiding this comment.
What kind is a URL in a doc comment?
There was a problem hiding this comment.
It's source.lang.swift.syntaxtype.comment.url:
/// See
/// https://apple.com
func foo() {}[
{
"length" : 8,
"offset" : 0,
"type" : "source.lang.swift.syntaxtype.doccomment"
},
{
"length" : 4,
"offset" : 8,
"type" : "source.lang.swift.syntaxtype.doccomment"
},
{
"length" : 17,
"offset" : 12,
"type" : "source.lang.swift.syntaxtype.comment.url"
},
{
"length" : 1,
"offset" : 29,
"type" : "source.lang.swift.syntaxtype.doccomment"
},
// ...
]There was a problem hiding this comment.
Right so shouldn't this check include comment URLs too then?
There was a problem hiding this comment.
Not really because it's the same syntax kind of a regular comment URL. Since there should be a source.lang.swift.syntaxtype.doccomment together, I think it's fine.
The case where this could lead to false negatives is /// URL as the doccomment piece would just be /// and then the exception for / only lines would avoid the violation to be triggered.
There was a problem hiding this comment.
Sounds good. Probably a good idea to add a test case to be sure though.
d3205a7 to
88d8200
Compare
|
Thanks for doing this! |
Fixes #2989
Making this enabled by default for now, I'll re-evaluate after OSSCheck is run.