Add Rubocop Linter to raise for hard-coded docs URLs in translations
Description
Including https://docs.gitlab.com/ee/
directly in a localized translation (or any application text that is shown to an end user) is problematic for several reasons:
- The docs URL could change and then we have a broken link
- The URL is not specific to the deployment where the message shows up
- Helper methods are easier to grep for / change in the case of a large refactor
For this reason, we should have a Rubocop linter that raises if a translation is added with https://docs.gitlab.com/ee/*
directly included. These URLs should instead us the help_page_path
helper: https://docs.gitlab.com/ee/development/documentation/#linking-to-help-in-ruby
More context:
Implementation Guide
- Add a custom Rubocop linter in https://gitlab.com/gitlab-org/gitlab/-/tree/master/rubocop/cop/gitlab
- Linter should do a Regex match for
https://docs.gitlab.com/ee/
- For help with writing the node matcher for the custom cop, you can use https://gitlab.com/gitlab-org/gitlab/-/blob/7a0d191291157d1eeabcda052156a6e3de55567e/scripts/rubocop-parse
- Linter error message should link to https://docs.gitlab.com/ee/development/documentation/#linking-to-help-in-ruby for docs on how to link to help pages in Ruby.
Edited by Jessie Young