Hive
feat(server): enforce stdlib JSON over Jason via credo check
GitHub issue · Closed
Source
tuist/tuist #10856
Updated
Jun 24, 2026
Adds a custom credo check that disallows direct
Jason.*usage in favor of Elixir’s built-inJSONmodule, and migrates the existing call sites.
What changed
- New custom credo check
Credo.Checks.DisallowJasonin tuist_common/credo/checks/, matching both function calls (Jason.encode!/decode!/...) and struct patterns (%Jason.DecodeError{}). - Check wired into
server/.credo.exs,cache/.credo.exs, andprocessor/.credo.exs. - 62 of 67
Jason.*call sites migrated toJSON.*across server/lib/ and server/test/. - In
license.ex, the%Jason.DecodeError{}pattern inresolve_certificate/2was replaced with{:error, reason}+inspect/1, sinceJSON.decode/1returns plain error reasons.
Edge cases kept on Jason
Elixir’s stdlib JSON module has no equivalents for these, so each site keeps Jason with an inline # credo:disable-for-next-line Credo.Checks.DisallowJason:
- 3 ×
Jason.encode!(_, pretty: true)—selective_testing_tab.ex,module_cache_tab.ex,webhook_event_live.ex. - 1 ×
Jason.decode!(_, keys: :atoms)—environment.ex(stripe price config).
How to test locally
cd server && mix credo --strict— runs cleanly.cd server && mix format --check-formatted— clean.cd server && TUIST_HOSTED=1 mix test test/tuist/license_test.exs test/tuist/kubernetes/client_test.exs test/tuist_web/plugs/webhook_plug_test.exs test/tuist_web/plugs/warnings_header_plug_test.exs ...— all 178 migrated tests pass. (TUIST_HOSTED=1only needed to bypass theOnPremisePluglicense-env check on the local API tests; same 422 reproduces without my changes.)- To verify the check fires, drop a fresh
Jason.encode!(x)anywhere inserver/lib/and runmix credo— it will flag it.
🤖 Generated with Claude Code
No GitHub comments yet.