Require that const_get does not inherit constant scope (false as 2nd arg)
Description of the proposal
Require const_get
calls to use false
as the second argument. This means const_get
calls don't retrieve constants from higher level scopes.
Consider the code below (in Rails, not pure Ruby):
module Gitlab
module Prometheus
end
end
module Prometheus
end
Object.const_get("Gitlab::Prometheus")
should not return the Prometheus
constant. It should return the Gitlab::Prometheus
.
This affects only development
and test
environments. production
is not affected because it eager_load
all constants.
MR that implements this: !18048 (merged)
-
Mention the proposal in the next backend weekly call and the #backend channel to encourage contribution -
Proceed with the proposal once 50% of the maintainers have weighed in, and 80% of the votes are 👍 -
Once approved, mention it again in the next backend weekly call and the #backend channel
/cc @gitlab-org/maintainers/rails-backend
See also
Edited by Thong Kuah