Skip to content

S10.22: Enum naming convention restoration (SCREAMING_SNAKE) #390

Description

@DavidCozens

Purpose

Restore a single, mechanically enforceable rule for enum constant naming, replacing the two-class system that has accumulated across S10.07 (Class_PascalCase introduction) and S10.12 (SCREAMING_SNAKE carve-out for the anonymous-enum named-constant idiom). The two-class system is not enforceable by .clang-tidy alone — it relies on per-site judgment about whether a constant is "macro-like" — and the drift is now visible: S10.16 review surfaced a third hybrid form (Class_DEFAULT_INSTANCE) that nobody had decided on.

Settle it once. One rule, one .clang-tidy setting, no IgnoredRegexp escape.

Decisions

  1. All enum constants → SCREAMING_SNAKE. Tagged or anonymous, public or TU-local.
  2. Public enums keep the project prefix. SOLIDSYSLOG_SEVERITY_EMERGENCY, SOLIDSYSLOG_FACILITY_USER, SOLIDSYSLOG_DATAGRAM_SEND_RESULT_SENT. Predictable, greppable, no collisions with platform headers (EMERGENCY etc. exist as <syslog.h> macros on Linux/BSD).
  3. TU-local anonymous-enum constants stay project-prefix-free where they are scoped to a single TU (IPV4_HEADER_BYTES, UINT32_MAX_DECIMAL_DIGITS). No change from today — only the case rule was the question.
  4. .clang-tidy EnumConstantCaseUPPER_CASE only. Drop the dual-form EnumConstantIgnoredRegexp escape. One rule, no exceptions.
  5. NAMING.md collapses to one rule. Remove the "anonymous-enum named-constant idiom" carve-out language from S10.12 — the carve-out is no longer needed; there's only one rule now.

Out of scope

  • Static variable naming (the instance / DEFAULT_INSTANCE / NIL_SENDER family). Those are objects, not enum constants. Will be decided incrementally in the in-flight per-group stories (S10.16 onwards), or in a dedicated cleanup if it becomes painful.
  • Per-group conformance work (S10.16–S10.19). Each resumes once S10.22 lands.
  • S10.20 warning→error flip + scope widening.

Scope (rough, firms up at survey)

Tagged enums currently using SolidSyslogClass_Member:

  • Core/Interface/SolidSyslogPrival.hSolidSyslogFacility_* (≈24 constants), SolidSyslogSeverity_* (8 constants)
  • Core/Interface/SolidSyslogTransport.hSolidSyslogTransport_* (≈2)
  • Core/Interface/SolidSyslogDatagram.hSolidSyslogDatagramSendResult_* (≈3)
  • Core/Interface/SolidSyslogBlockStore.hSolidSyslogDiscardPolicy_* (≈3)
  • Plus any others surfaced by survey (SolidSyslog[A-Z][a-z][a-zA-Z]*_[A-Z][a-z] matches)

Anonymous enums (SOLIDSYSLOG_*_SIZE etc.) are already SCREAMING — no change.

Files touched by call-site renames: Core/, Platform/, Bdd/, Tests/, examples/, docs/.

Tooling:

  • docs/NAMING.md — collapse two-rule → one-rule
  • .clang-tidyEnumConstantCaseUPPER_CASE, drop EnumConstantIgnoredRegexp

Workflow

  1. Survey. Enumerate every SolidSyslog[A-Z][a-z][a-zA-Z]*_[A-Z][a-z] enum constant tree-wide. Confirm scope before any rename.
  2. Sweep, one commit per enum tag. Sed-driven for the mechanical bulk; regex reviewed before each invocation. Per-enum granularity so a regression bisects cleanly.
  3. Tooling commit. .clang-tidy + NAMING.md together.
  4. Gate sweep. debug, clang-debug, sanitize, coverage, tidy, cppcheck, cppcheck-misra. Must be green.
  5. DEVLOG. Capture the convention change + reasoning + reference back to S10.07 / S10.12 history.

Acceptance

  • Single .clang-tidy rule for enum constants, no IgnoredRegexp escape.
  • NAMING.md documents one enum rule, no carve-outs.
  • Zero new findings from analyze-tidy / analyze-cppcheck tree-wide.
  • 100% line + function coverage preserved.
  • Full test suite green across debug, clang-debug, sanitize, tidy, cppcheck, coverage presets.
  • DEVLOG entry appended on the same branch, before opening the PR.

Risk

  • Sweep PR diff will be large but mechanical. Per-enum commits keep bisect viable.
  • Public-API enums change form — but the project is pre-1.0 with no released ABI, so callers absorb the rename in one go.
  • SOLIDSYSLOG_SEVERITY_EMERGENCY etc. are greppable and don't collide with <syslog.h>'s unprefixed EMERGENCY.

Parent epic: #12

Metadata

Metadata

Assignees

No one assigned

    Labels

    storyStory issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions