Skip to content

Refactor ExtractsRef into class

euko requested to merge 422133-move-extract-ref-path-modules-to-concerns into master

Background

ExtractsRef (lib/extracts_path.rb) and ExtractsPath (lib/extracts_ref.rb) are modules used to extract various git related strings from request parameters.

There are two problems with the modules.

  1. Contrary to what their location indicates (lib), they have been written to be used as controller concerns and the vast majority of their consumers are Rails controllers.

  2. They extensively use instance variables to achieve their goals and it's hard to reason about the code !131125 (comment 1546934017).

What does this MR do and why?

  • This MR creates ExtractsRef::RefExtractor, a refactored class version of ExtractsRef.

  • Swap out ExtractsRef with ExtractsRef::RefExtractor throughout the codebase.

  • ExtractsRef is refactored to use ExtractsRef::RefExtractor whenever possible.

    ExtractsRef is not removed and is left in place because ExtractsPath depends on ExtractsRef in a convoluted manner. I created a dedicated issue to refactor ExtractsPath #425379.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #422133 (closed)

Edited by euko

Merge request reports