Commit ddef57af authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'fix-static-check-delegator-validator' into 'master'

Fix Delegator Override Validator does not work without DB

See merge request gitlab-org/gitlab!71466
parents 414283f0 0b03771a
......@@ -35,6 +35,17 @@ static-analysis:
paths:
- tmp/feature_flags/
static-analysis-with-database:
extends:
- .static-analysis-base
- .static-analysis:rules:ee-and-foss
- .use-pg12
stage: test
script:
- bundle exec rake lint:static_verification_with_database
variables:
SETUP_DB: "true"
static-analysis as-if-foss:
extends:
- static-analysis
......
......@@ -51,7 +51,13 @@ module Gitlab
# Workaround to fully load the instance methods in the target class.
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69823#note_678887402
target_classes.map(&:new) rescue nil
begin
target_classes.map(&:new)
rescue ArgumentError
# Some models might raise ArgumentError here, but it's fine in this case,
# because this is enough to force ActiveRecord to generate the methods we
# need to verify, so it's safe to ignore it.
end
(delegator_class.instance_methods - allowlist).each do |method_name|
target_classes.each do |target_class|
......
......@@ -12,6 +12,13 @@ unless Rails.env.production?
dev:load
] do
Gitlab::Utils::Override.verify!
end
desc "GitLab | Lint | Static verification with database"
task static_verification_with_database: %w[
lint:static_verification_env
dev:load
] do
Gitlab::Utils::DelegatorOverride.verify!
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment