-
-
Notifications
You must be signed in to change notification settings - Fork 756
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
Article descriptions - Add casing warning label for non-EN wikis #3883
Conversation
Should this be based off this PR? |
This is waiting on #3880 to be merged. |
This is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments. Overall this looks great, and tests great!
guard let firstCharacter = description?.first, | ||
firstCharacter.isLetter, | ||
firstCharacter.isUppercase else { | ||
return warningTypes | ||
} | ||
|
||
warningTypes.insert(.casing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, it's more readable if something like this. Personal preference though.
guard let firstCharacter = description?.first, | |
firstCharacter.isLetter, | |
firstCharacter.isUppercase else { | |
return warningTypes | |
} | |
warningTypes.insert(.casing) | |
if let firstCharacter = description?.first, | |
firstCharacter.isLetter, | |
firstCharacter.isUppercase { | |
warningTypes.insert(.casing) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcleinman done!
@@ -14,8 +21,16 @@ protocol ArticleDescriptionControlling { | |||
func currentDescription(completion: @escaping (String?) -> Void) | |||
func errorTextFromError(_ error: Error) -> String | |||
func learnMoreViewControllerWithTheme(_ theme: Theme) -> UIViewController? | |||
var descriptionMaxLength: Int { get } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a bug, but not sure you need this line - I think you can get away with just having the variable int he protocol extension if you want. This is definitely a personal style preference, please feel very free to disagree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcleinman yep agreed, I don't see the reason to keep it here if we're not overriding/swapping out the implementation anywhere.
} | ||
|
||
extension ArticleDescriptionControlling { | ||
var articleDisplayTitle: String? { return article.displayTitle } | ||
var descriptionMaxLength: Int { return 90 } | ||
|
||
func descriptionIsTooLong(_ description: String?) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have descriptionIsTooLong
in the extension, but the "check capitalization of first letter" function lives in a class. Maybe we should standardize this? Either all the check functions can be in here, or none?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcleinman sounds good, I have moved the capitalization check into the extension. Originally descriptionIsTooLong
was just code used in both classes, so I moved it to an extension to share code. Since the capitalization logic was only used in one place there was less of a need, but it feels better now that they're matching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more code style thing, but only if you want to update it. (Feel free to merge if it's not worthwhile.) Works great and tests great.
if let firstCharacter = description?.first, | ||
firstCharacter.isLetter, | ||
firstCharacter.isUppercase { | ||
return true | ||
} | ||
|
||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be more concise if you wanted:
guard let firstCharacter = description?.first else {
return false
}
return firstCharacter.isLetter && firstCharacter.isUppercase
(I think I remember us talking about providing more detailed PR suggestions. If I'm wrong or you don't like this, don't worry about it - works great as is. Just let me know to stand down. :) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, this is done!
Fixes Phabricator ticket: https://phabricator.wikimedia.org/T261977
Notes
This adds an extra warning label for users that begin their non-EN wiki article descriptions with a lowercase letter. It does not block publishing though, in case they are starting with a proper noun. Do not review until #3880 is merged and this PR is updated with
main
to clean up the diff.Test Steps
Screenshots/Videos (if applicable)
(Non-EN examples)