diff options
20 files changed, 45 insertions, 2 deletions
diff --git a/app/validators/abstract_path_validator.rb b/app/validators/abstract_path_validator.rb index e43b66cbe3a..45ac695c5ec 100644 --- a/app/validators/abstract_path_validator.rb +++ b/app/validators/abstract_path_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AbstractPathValidator < ActiveModel::EachValidator extend Gitlab::EncodingHelper diff --git a/app/validators/certificate_fingerprint_validator.rb b/app/validators/certificate_fingerprint_validator.rb index 17df756183a..79d78653ec7 100644 --- a/app/validators/certificate_fingerprint_validator.rb +++ b/app/validators/certificate_fingerprint_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CertificateFingerprintValidator < ActiveModel::EachValidator FINGERPRINT_PATTERN = /\A([a-zA-Z0-9]{2}[\s\-:]?){16,}\z/.freeze diff --git a/app/validators/certificate_key_validator.rb b/app/validators/certificate_key_validator.rb index 8c7bb750339..5b2bbffc066 100644 --- a/app/validators/certificate_key_validator.rb +++ b/app/validators/certificate_key_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # UrlValidator # # Custom validator for private keys. diff --git a/app/validators/certificate_validator.rb b/app/validators/certificate_validator.rb index b0c9a1b92a4..de8bb179dfb 100644 --- a/app/validators/certificate_validator.rb +++ b/app/validators/certificate_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # UrlValidator # # Custom validator for private keys. diff --git a/app/validators/cluster_name_validator.rb b/app/validators/cluster_name_validator.rb index e7d32550176..85fd63f08e5 100644 --- a/app/validators/cluster_name_validator.rb +++ b/app/validators/cluster_name_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # ClusterNameValidator # # Custom validator for ClusterName. diff --git a/app/validators/color_validator.rb b/app/validators/color_validator.rb index 571d0007aa2..1932d042e83 100644 --- a/app/validators/color_validator.rb +++ b/app/validators/color_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # ColorValidator # # Custom validator for web color codes. It requires the leading hash symbol and diff --git a/app/validators/cron_timezone_validator.rb b/app/validators/cron_timezone_validator.rb index 542c7d006ad..c5f51d65060 100644 --- a/app/validators/cron_timezone_validator.rb +++ b/app/validators/cron_timezone_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # CronTimezoneValidator # # Custom validator for CronTimezone. diff --git a/app/validators/cron_validator.rb b/app/validators/cron_validator.rb index 981fade47a6..bd48a7a6efb 100644 --- a/app/validators/cron_validator.rb +++ b/app/validators/cron_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # CronValidator # # Custom validator for Cron. diff --git a/app/validators/duration_validator.rb b/app/validators/duration_validator.rb index 10ff44031c6..811828169ca 100644 --- a/app/validators/duration_validator.rb +++ b/app/validators/duration_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # DurationValidator # # Validate the format conforms with ChronicDuration diff --git a/app/validators/email_validator.rb b/app/validators/email_validator.rb index aab07a7ece4..9459edb7515 100644 --- a/app/validators/email_validator.rb +++ b/app/validators/email_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class EmailValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) record.errors.add(attribute, :invalid) unless value =~ Devise.email_regexp diff --git a/app/validators/key_restriction_validator.rb b/app/validators/key_restriction_validator.rb index 204be827941..891d13b1596 100644 --- a/app/validators/key_restriction_validator.rb +++ b/app/validators/key_restriction_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class KeyRestrictionValidator < ActiveModel::EachValidator FORBIDDEN = -1 diff --git a/app/validators/line_code_validator.rb b/app/validators/line_code_validator.rb index ed29e5aeb67..a351180790e 100644 --- a/app/validators/line_code_validator.rb +++ b/app/validators/line_code_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # LineCodeValidator # # Custom validator for GitLab line codes. diff --git a/app/validators/namespace_name_validator.rb b/app/validators/namespace_name_validator.rb index 2e51af2982d..fb1c241037c 100644 --- a/app/validators/namespace_name_validator.rb +++ b/app/validators/namespace_name_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # NamespaceNameValidator # # Custom validator for GitLab namespace name strings. diff --git a/app/validators/namespace_path_validator.rb b/app/validators/namespace_path_validator.rb index 7b0ae4db5d4..c078b272b2f 100644 --- a/app/validators/namespace_path_validator.rb +++ b/app/validators/namespace_path_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class NamespacePathValidator < AbstractPathValidator extend Gitlab::EncodingHelper diff --git a/app/validators/project_path_validator.rb b/app/validators/project_path_validator.rb index 424fd77a6a3..aea0a68e7cf 100644 --- a/app/validators/project_path_validator.rb +++ b/app/validators/project_path_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ProjectPathValidator < AbstractPathValidator extend Gitlab::EncodingHelper diff --git a/app/validators/public_url_validator.rb b/app/validators/public_url_validator.rb index 1e8118fccbb..3ff880deedd 100644 --- a/app/validators/public_url_validator.rb +++ b/app/validators/public_url_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # PublicUrlValidator # # Custom validator for URLs. This validator works like UrlValidator but diff --git a/app/validators/top_level_group_validator.rb b/app/validators/top_level_group_validator.rb index 7e2e735e0cf..b50c9dca154 100644 --- a/app/validators/top_level_group_validator.rb +++ b/app/validators/top_level_group_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TopLevelGroupValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if value&.subgroup? diff --git a/app/validators/url_validator.rb b/app/validators/url_validator.rb index 6854fec582e..faaf1283078 100644 --- a/app/validators/url_validator.rb +++ b/app/validators/url_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # UrlValidator # # Custom validator for URLs. diff --git a/app/validators/variable_duplicates_validator.rb b/app/validators/variable_duplicates_validator.rb index 72660be6c43..90193e85f2a 100644 --- a/app/validators/variable_duplicates_validator.rb +++ b/app/validators/variable_duplicates_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # VariableDuplicatesValidator # # This validator is designed for especially the following condition @@ -22,8 +24,8 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator def validate_duplicates(record, attribute, values) duplicates = values.reject(&:marked_for_destruction?).group_by(&:key).select { |_, v| v.many? }.map(&:first) if duplicates.any? - error_message = "have duplicate values (#{duplicates.join(", ")})" - error_message += " for #{values.first.send(options[:scope])} scope" if options[:scope] # rubocop:disable GitlabSecurity/PublicSend + error_message = +"have duplicate values (#{duplicates.join(", ")})" + error_message << " for #{values.first.send(options[:scope])} scope" if options[:scope] # rubocop:disable GitlabSecurity/PublicSend record.errors.add(attribute, error_message) end end diff --git a/changelogs/unreleased/frozen-string-enable-app-validators.yml b/changelogs/unreleased/frozen-string-enable-app-validators.yml new file mode 100644 index 00000000000..db480b06d9b --- /dev/null +++ b/changelogs/unreleased/frozen-string-enable-app-validators.yml @@ -0,0 +1,5 @@ +--- +title: Enable frozen string in apps/validators/*.rb +merge_request: 20220 +author: gfyoung +type: other |