-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift 2.3 or later break docs-related rules like missing_docs and valid_docs #728
Comments
Hi @mattrubin, sorry about that 😬. I labeled this as a bug, hopefully someone can look into it soon. Related: the |
I believe If I can find the time, I'll try to track down the cause of the issue myself. I'm not very familiar with SourceKit(ten), though. Any initial suggestions, or thoughts on why Swift 3 might have broken this? |
Having the same issue |
Having the same issue! @jpsim any solution? |
This issue is caused by change of SourceKit's behavior on Swift 3.0. jpsim/SourceKitten#269 |
The SourceKit behavior we rely on for docs-related rules like The best way to make progress on this regression is for users affected to lend their voice and comment on SR-2487 to explain how you're affected and why it'd be useful for the feature to be added back in. |
I have the same issue with the upcoming false positive warnings! |
This rule will be disabled when using Swift 2.3 or later on the next release, because there was a regression on SourceKit (https://bugs.swift.org/browse/SR-2487). As @jpsim told, the best you can do is to comment on that issue (and not here). |
Until the SourceKit bug is fixed, I've added a custom rule within my missing_docs:
included: ".*.swift"
regex: '\n *(?!\/\/\/)(\/\/)?[^\n\/]*\n *(?:public|open)'
name: "Missing Docs"
message: "Types, properties and methods with public or open access level should be documented."
severity: warning This might not be as good as the previous implementation, but it works for most cases for me. It is relying on the |
@Dschee Nice. To help others, you need to put this rule below a custom_rules:
missing_docs:
included: ".*.swift"
# etc. One thing this doesn't support is putting '@' modifiers on their own line before a public definition, such as Example: /// Remove a given key and the associated value.
///
/// - parameters:
/// - key: The key for the value to remove.
///
/// - returns: The value that was removed, or `nil` if the key is not present.
@discardableResult
public func removeValue(forKey key: String) -> Value? {
// Code to remove the value.
} Thanks, |
@Tableau-David-Potter Thanks for the custom_rule pointer. Regarding your example, I couldn't come up with a solution quickly for not marking that line. But given this situation, I came up with an example, that actually didn't work with the rule up until now. As an example, I would expect this to be marked with a missing_docs warning, too: // some other code
@discardableResult public func removeValue(forKey key: String) -> Value? {
// Code to remove the value.
} But the custom rule didn't cover that case. So I've changed the regex to this: \n *(?!\/\/\/)(\/\/)?[^\n\/]*\n *(?:@\S+ )*(?:public|open) So, although this doesn't solve your problem yet, my updated custom rule looks like this: custom_rules:
missing_docs:
included: ".*.swift"
regex: '\n *(?!\/\/\/)(\/\/)?[^\n\/]*\n *(?:@\S+ )*(?:public|open)'
name: "Missing Docs"
message: "Types, properties and methods with public or open access level should be documented."
severity: warning Regarding your issue, if you find the missing_docs rule more important than your style guide to put those The alternative is of course that you make an exception by adding |
I've again tried to update the regex without success. I'm not sure if it's even possible. Here's how I deal with such situations now though – just placing the @discardableResult
/// Remove a given key and the associated value.
///
/// - parameters:
/// - key: The key for the value to remove.
///
/// - returns: The value that was removed, or `nil` if the key is not present.
public func removeValue(forKey key: String) -> Value? {
// Code to remove the value.
} |
After converting my project to Swift 3, SwiftLint warns about missing docs for nearly every public declaration. All of these declarations do have documentation comments (
///
) and withmissing_docs
enabled there were no warnings for Swift 2.3.The issue is reproducible with Xcode 8 beta 3, SwiftLint 0.11.1, and this project:
https://github.com/mattrubin/OneTimePassword/tree/8e7ec68c03f80da6dddb41a422678f08ab7d9bdbThe text was updated successfully, but these errors were encountered: