Tptp.Checks.NoDynamicAtoms (Tptp v0.1.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of high and works with any version of Elixir.

Explanation

Atoms are never garbage collected and the VM's table holds around a million of them. This library reads other people's files — tens of thousands of them in a corpus run — so turning a functor, a formula name or a role into an atom is a denial-of-service waiting to happen, not merely a leak.

Every atom this library uses is created at compile time: node kinds and token categories come from the generated grammar, and the :== vocabularies come from Tptp.Bnf.Vocabulary. Where input must reach an atom at all, use String.to_existing_atom/1 inside a closed vocabulary and handle the ArgumentError.

# not this
String.to_atom(functor)

# this
Tptp.Bnf.Vocabulary.formula_role?(role)

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.

Summary

Functions

The calls this check refuses, as {module, function} pairs.

Functions

forbidden()

@spec forbidden() :: [{module(), atom()}]

The calls this check refuses, as {module, function} pairs.

Exposed so the test suite can assert that each one names a function that exists. A misspelling here is invisible in the worst way: the check goes on reporting no issues, which is what a clean tree looks like. String.to_charlist_atom sat in this list until 2026-09-09 and could never have fired.

:erlang.binary_to_term/1 is here because it creates atoms from a serialised term. Module.concat/1,2 creates them too and is deliberately absent: its uses in this repository are all over compile-time alias AST, and a check that flags its own implementation teaches contributors to ignore it.