Skip to content
代码片段 群组 项目
未验证 提交 577be505 编辑于 作者: Peter Leitzen's avatar Peter Leitzen
浏览文件

Mark feature flags in Gitlab/MarkUsedFeatureFlags only once

Mark dynamic feature flags and feature flags for usage data counters
only once per whole rubocop run instead of once per file.

This reduces the overall runtime of this cop drastically:

    time bundle exec rubocop -C false -f q --only Gitlab/MarkUsedFeatureFlags

* Before: ~8m53.589s
* After: ~3m56.036s
上级 fa1c9710
No related branches found
No related tags found
2 合并请求!106Draft: This MR is specified for doc sync check,!105Draft:This MR is specified for docsynccheck, will not be merged
......@@ -47,10 +47,21 @@ class MarkUsedFeatureFlags < RuboCop::Cop::Cop
:usage_data_static_site_editor_merge_requests # https://gitlab.com/gitlab-org/gitlab/-/issues/284083
].freeze
class << self
# We track feature flags in `on_new_investigation` only once per
# rubocop whole run instead once per file.
attr_accessor :feature_flags_already_tracked
end
# Called before all on_... have been called
# When refining this method, always call `super`
def on_new_investigation
super
return if self.class.feature_flags_already_tracked
self.class.feature_flags_already_tracked = true
track_dynamic_feature_flags!
track_usage_data_counters_known_events!
end
......
......@@ -16,6 +16,7 @@
stub_const("#{described_class}::DYNAMIC_FEATURE_FLAGS", [])
allow(cop).to receive(:defined_feature_flags).and_return(defined_feature_flags)
allow(cop).to receive(:usage_data_counters_known_event_feature_flags).and_return([])
described_class.feature_flags_already_tracked = false
end
def feature_flag_path(feature_flag_name)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册