Hive Hive
Sign in

feat(server): enforce stdlib JSON over Jason via credo check

GitHub issue · Closed

Metadata
Source
tuist/tuist #10856
Updated
Jun 24, 2026
Details

Adds a custom credo check that disallows direct Jason.* usage in favor of Elixir’s built-in JSON module, and migrates the existing call sites.

What changed

  • New custom credo check Credo.Checks.DisallowJason in 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, and processor/.credo.exs.
  • 62 of 67 Jason.* call sites migrated to JSON.* across server/lib/ and server/test/.
  • In license.ex, the %Jason.DecodeError{} pattern in resolve_certificate/2 was replaced with {:error, reason} + inspect/1, since JSON.decode/1 returns 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=1 only needed to bypass the OnPremisePlug license-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 in server/lib/ and run mix credo — it will flag it.

🤖 Generated with Claude Code

Comments

No GitHub comments yet.