Some code in rake tasks can polute the global scope
This is more a gitlab-ce~4107678 discussion that calls for an investigation. I learned today that there are many ways we can pollute the global scope in a `.rake` file.
This like: `include`, `extend` are particularly problematic. Other things have unexpected behavior: Defining a constant outside a namespace, defines it in the global scope. Defining it inside a namespace, makes it available to the whole namespace, even in other files. So innocent things like `CACHE_TTL` or `LEASE_KEY` can have undesired behavior if the name exists in different rake files with different values.
Defining methods also are problematic. Outside a namespace = global scope. Inside a namespace, shared between all rake files that use the same namespace.
Few links with some useful information:
* https://stackoverflow.com/questions/37927452/is-it-possible-to-include-a-module-in-rake-tasks-without-polluting-the-global-sc
* https://kevinjalbert.com/defined_methods-in-rake-tasks-you-re-gonna-have-a-bad-time/
----
One possible strategy to fix this is to refactor existing rake tasks that define methods or constants into specific `Feature::RakeHelper` module, that will be called using full namespace format, ex: `AwesomeFeature::RakeHelper.awesome_rake_method('with content')`.
The strategy above is useful for auxiliary methods. Full blown transactional operations, should better be fitted into ServiceObjects.
cc @DouweM @rymai @stanhu @mek
issue