Skip to content

Enable Gitlab/Json cop

Robert May requested to merge json-cop-autocorrects into master

Description of the proposal

Enable the Gitlab/Json cop, which enforces usage of the Gitlab::Json wrapper over calling JSON directly. This is part of the work in #211671 (closed).

By removing any direct usage of JSON we remove the need to redefine that constant when swapping JSON libraries, e.g. introducing oj later. Using a wrapper class also allows us to swap the adapter based on other conditions (such as feature flags) and add performance metrics.

I've already fixed existing instances in the following merges:

Related #211671 (closed)

Check-list

  • Make sure this MR enables a static analysis check rule for new usage but ignores current offenses
  • Mention this proposal in the relevant Slack channels (e.g. #development, #backend, #frontend)
  • The MR doesn't have significant objections, and is getting a majority of 👍 vs 👎 (remember that we don't need to reach a consensus)
  • Create a follow-up issue to fix the current offenses as a separate iteration: ISSUE_LINK
  • Follow the review process as usual
  • Once approved and merged by a maintainer, mention it again:
    • In the relevant Slack channels (e.g. #development, #backend, #frontend)
    • (Optional depending on the impact of the change) In the Engineering Week in Review
Edited by Robert May

Merge request reports

Loading