diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-06 15:11:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-06 15:11:09 +0300 |
commit | e9aabbc4b5c80a569ce7e5909bd9d8def11b7a1b (patch) | |
tree | 2bc9ed254deba51c4041c1ee2fb8dcc7bd3dfaad /rubocop | |
parent | 08608c8e9e9821858dd2f452a3c9ebfb945ab69f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r-- | rubocop/batched_background_migrations_dictionary.rb | 7 | ||||
-rw-r--r-- | rubocop/cop/background_migration/dictionary_file.rb | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/rubocop/batched_background_migrations_dictionary.rb b/rubocop/batched_background_migrations_dictionary.rb index 286f0a57bad..70892d20796 100644 --- a/rubocop/batched_background_migrations_dictionary.rb +++ b/rubocop/batched_background_migrations_dictionary.rb @@ -16,7 +16,8 @@ module RuboCop data[dictionary['queued_migration_version'].to_s] = { introduced_by_url: dictionary['introduced_by_url'], finalize_after: dictionary['finalize_after'], - finalized_by: dictionary['finalized_by'].to_s + finalized_by: dictionary['finalized_by'].to_s, + milestone: dictionary['milestone'] } end end @@ -38,6 +39,10 @@ module RuboCop dictionary_data&.dig(:introduced_by_url) end + def milestone + dictionary_data&.dig(:milestone) + end + private def dictionary_data diff --git a/rubocop/cop/background_migration/dictionary_file.rb b/rubocop/cop/background_migration/dictionary_file.rb index 90a42135c41..abdcd7c3358 100644 --- a/rubocop/cop/background_migration/dictionary_file.rb +++ b/rubocop/cop/background_migration/dictionary_file.rb @@ -14,6 +14,7 @@ module RuboCop MSG = { invalid_url: "Invalid `%{key}` url for the dictionary. Please use the following format: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/XXX", + invalid_milestone: "Invalid `%{key}` for the dictionary. It must be a string. Please ensure it is quoted.", 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}. @@ -56,6 +57,10 @@ module RuboCop url.match?(URL_PATTERN) end + def valid_milestone?(milestone) + milestone.is_a?(String) + end + def dictionary_file?(migration_class_name) File.exist?(dictionary_file_path(migration_class_name)) end @@ -71,6 +76,10 @@ module RuboCop bbm_dictionary = RuboCop::BatchedBackgroundMigrationsDictionary.new(version(node)) + return [:missing_key, { key: :milestone }] unless bbm_dictionary.milestone.present? + + return [:invalid_milestone, { key: :milestone }] unless valid_milestone?(bbm_dictionary.milestone) + 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? |