Skip to content

Add OpenStructInheritance Cop

Matthias Käppler requested to merge open-struct-inheritance-cop into master

Description of the proposal

gitlab-org/gitlab#343421 (closed)


NOTE: There are 2 competing proposals, this one, and https://gitlab.com/gitlab-org/gitlab-styles/-/merge_requests/92. Please vote only once using 👍/👎 on either MR. Assuming one MR gets enough votes, the one with more 👍 wins.


During the Ruby 3 migration, we ran into very subtle issues with a class that inherited from OpenStruct. An example + explanation can be found in this MR: gitlab-org/gitlab!67855 (merged)

While working on Ruby 3 migration docs, it was suggested to flag these uses using a Cop instead of just documentation: gitlab-org/gitlab!70609 (merged)

This implementation adds a Cop specific to the issue we ran into (inheritance related) rather than a catch-all Cop. It therefore complements, not supplants, Performance/OpenStruct.

Check-list

  • Mention this proposal in the relevant Slack channels (e.g. #development, #backend, #frontend)
  • If there is a choice to make between two potential styles, set up an emoji vote in the MR:
    • CHOICE_A: 🅰
    • CHOICE_B: 🅱
    • Vote yourself for both choices so that people know these are the choices
  • The MR doesn't have significant objections, and is getting a majority of 👍 vs 👎 (remember that we don't need to reach a consensus)
  • (If applicable) One style is getting a majority of vote (compared to the other choice)
  • (If applicable) Update the MR with the chosen style
  • Follow the review process as usual

/cc @gitlab-org/maintainers/rails-backend

Edited by Matthias Käppler

Merge request reports

Loading