Skip to content

Refactor api/entities.rb into multiple files

Summary

lib/api/entities.rb has almost 2000 lines of code and contains about 170 classes. We also have a few entities organized in lib/api/entities

We want to refactor it so each entity class is in its own file under lib/api/entities.

Improvements

This would make it easier to write unit tests and entities would be easier to find in the codebase.

Risks

Entities are an essential part of the REST API and there are only a few unit tests for them. On the other hand, the classes are very simple.

To avoid problems I think it would be good to add specs for entities that do more than just exposing simple fields.

Involved components

https://gitlab.com/gitlab-org/gitlab/blob/master/lib/api/entities.rb