diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-01 21:14:38 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-01 21:14:38 +0300 |
commit | 07cbb41fee42601767b3aea2979d6fa6d990ce5b (patch) | |
tree | 00ba0463347c4e2951660c7236652bb24750976d /rubocop | |
parent | c3ddbeb162e4261f4ce3df291909fadeba637995 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r-- | rubocop/cop/background_migration/dictionary_file.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/rubocop/cop/background_migration/dictionary_file.rb b/rubocop/cop/background_migration/dictionary_file.rb index 9ae47260e79..90a42135c41 100644 --- a/rubocop/cop/background_migration/dictionary_file.rb +++ b/rubocop/cop/background_migration/dictionary_file.rb @@ -3,6 +3,8 @@ require_relative '../../migration_helpers' require_relative '../../batched_background_migrations_dictionary' +URL_PATTERN = %r{\Ahttps://gitlab\.com/gitlab-org/gitlab/-/merge_requests/\d+\z} + module RuboCop module Cop module BackgroundMigration @@ -11,6 +13,7 @@ module RuboCop include MigrationHelpers MSG = { + invalid_url: "Invalid `%{key}` url for the dictionary. Please use the following format: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/XXX", missing_key: "Mandatory key '%{key}' is missing from the dictionary. Please add with an appropriate value.", missing_dictionary: <<-MESSAGE.delete("\n").squeeze(' ').strip Missing %{file_name}. @@ -49,6 +52,10 @@ module RuboCop private + def valid_url?(url) + url.match?(URL_PATTERN) + end + def dictionary_file?(migration_class_name) File.exist?(dictionary_file_path(migration_class_name)) end @@ -67,6 +74,8 @@ module RuboCop return [:missing_key, { key: :finalize_after }] unless bbm_dictionary.finalize_after.present? return [:missing_key, { key: :introduced_by_url }] unless bbm_dictionary.introduced_by_url.present? + + return [:invalid_url, { key: :introduced_by_url }] unless valid_url?(bbm_dictionary.introduced_by_url) end def rails_root |