Skip to content
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

Merged
merged 6 commits into from
Mar 26, 2021

Conversation

tonisevener
Copy link
Collaborator

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

  1. On a non-EN wiki article, edit or add an article description. Confirm that if description starts with an uppercase letter, you see the red label about casing as stated in the Phab task. Confirm if you enter > 90 characters, you see both the casing labels and the length labels. Confirm if you enter > 90 characters and the description begins with a lowercase letter, you only see the length label.
  2. On an EN wiki article, edit or add an article description. Confirm you only see a length label if you enter > 90 characters, and you never see the red casing label.

Screenshots/Videos (if applicable)

(Non-EN examples)
Screen Shot 2021-03-10 at 1 38 08 PM
Screen Shot 2021-03-10 at 1 38 03 PM
Screen Shot 2021-03-10 at 1 37 59 PM

@tonisevener tonisevener added Hold Dependent PR PR is dependent on another PR - merge dependent PR first and update branch before merging labels Mar 10, 2021
@tonisevener tonisevener requested review from a team, staykids and mcleinman and removed request for a team and staykids March 10, 2021 19:41
@mcleinman
Copy link
Contributor

Should this be based off this PR?

@mcleinman mcleinman changed the base branch from main to T25786-2 March 17, 2021 23:41
@mcleinman mcleinman changed the base branch from T25786-2 to main March 17, 2021 23:42
@mcleinman mcleinman changed the base branch from main to T25786-2 March 17, 2021 23:43
@mcleinman mcleinman changed the base branch from T25786-2 to main March 17, 2021 23:44
@mcleinman
Copy link
Contributor

This is waiting on #3880 to be merged.

@tonisevener tonisevener removed Hold Dependent PR PR is dependent on another PR - merge dependent PR first and update branch before merging labels Mar 22, 2021
@tonisevener
Copy link
Collaborator Author

This is ready for review.

Copy link
Contributor

@mcleinman mcleinman left a 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!

Comment on lines 61 to 67
guard let firstCharacter = description?.first,
firstCharacter.isLetter,
firstCharacter.isUppercase else {
return warningTypes
}

warningTypes.insert(.casing)
Copy link
Contributor

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.

Suggested change
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)
}

Copy link
Collaborator Author

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 }
Copy link
Contributor

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.

Copy link
Collaborator Author

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 {
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Contributor

@mcleinman mcleinman left a 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.

Comment on lines 37 to 43
if let firstCharacter = description?.first,
firstCharacter.isLetter,
firstCharacter.isUppercase {
return true
}

return false
Copy link
Contributor

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. :) )

Copy link
Collaborator Author

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!

@tonisevener tonisevener merged commit 4aae27b into main Mar 26, 2021
@tonisevener tonisevener deleted the T261977 branch March 26, 2021 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants