Remove unused Prometheus cache methods from Environment and its concern
What does this MR do and why
Environment#clear_prometheus_reactive_cache! and
Environment#cluster_prometheus_adapter are unreachable:
clear_prometheus_reactive_cache!has no caller anywhere in the repository,ee/included.cluster_prometheus_adapteris called only from that method, so it dies with it.
Environment does not include the PrometheusAdapter concern, so neither
method overrides anything: the includes are StrongMemoize,
ReactiveCaching, CacheMarkdownField, FastDestroyAll::Helpers,
Presentable, NullifyIfBlank and FromUnion.
cluster_prometheus_adapter was also broken independently of being unused.
It called ::Gitlab::Prometheus::Adapter#cluster_prometheus_adapter, and
that class only defines prometheus_adapter and
find_cluster_prometheus_adapter, so the call would raise NoMethodError
if anything reached it.
Removing those two leaves
PrometheusAdapter#clear_prometheus_reactive_cache! without a caller,
because the body being deleted was its only one. This MR removes that
method as well, so the change does not leave newly dead code behind.
The cascade stops there. The two neighbours in the concern,
query_klass_for and build_query_args, are still called from
PrometheusAdapter#query.
I did not spot the cascade myself: the static-analysis job did. Keela
reported new unused code on the first revision of this MR, which is
exactly what it is for.
How to verify
- Search the repository for
clear_prometheus_reactive_cache. Before this MR the only hits are the concern definition, theEnvironmentdefinition, and the call from the latter into the former. - Check the
includelist at the top ofapp/models/environment.rb. - Check
Gitlab::Prometheus::Adapterinlib/gitlab/prometheus/adapter.rb: nocluster_prometheus_adapter. query_klass_forandbuild_query_argskeep their callers inPrometheusAdapter#query.
Spotted by itaruby(to be released), a Ruby type checker I'm working on.