Skip to content

Use explicit boolean attributes and support formatting #511

Description

@SJrX

It'd maybe be nice if we could automatically force in preferences somewhere (I dunno about code style), that booleans should be a certain type and then throw a weak warning with a fix anywhere that isn't true, i.e., forcing On/Off or Yes/No instead of 0/1 etc...

One challenge is that we probably need to remove the old parser for this as well.

Here are some notes of some problematic validators:

he new parse engine explores every alternative, so once that's the only parser,
  AlternativeCombinator(enum, BOOLEAN) is safe regardless of order and the whole thing becomes a mechanical find-and-replace instead of ten individual source checks.

  Paste-able list for the note:

  Inline parse_boolean() spellings merged into an enum terminal
  (should be AlternativeCombinator(<enum>, BOOLEAN) once the classic engine is gone):

    ConfigParseProtectSystemOptionValue          full, strict
    ConfigParseProtectHomeOptionValue            read-only, tmpfs
    ConfigParseProtectHostnameOptionValue        private
    ConfigParseProtectControlGroupsOptionValue   private, strict
    ConfigParsePrivateTmpOptionValue             disconnected
    ConfigParseKeepConfigurationOptionValue      dhcp, dhcp-on-stop, static
    ConfigParseIpv6PrivacyExtensionsOptionValue  prefer-public, kernel
    ConfigParseIpMasqueradeOptionValue           ipv4, ipv6, both
    ConfigParseDhcpServerPersistLeasesOptionValue runtime
    ConfigParseDfOptionValue                     inherit
    ConfigParseCakeTristateOptionValue           (booleans only — just use BOOLEAN)

  Blocked on: classic SyntacticMatch/SemanticMatch engine removal. Until then each split
  needs the enum ordered before BOOLEAN and verified per-file, since BOOLEAN matches a
  prefix (`no` out of `none`) and the classic matcher can't backtrack.

  Let me correct one thing I wrote into my own notes earlier in this session, since it was the mistake you caught:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions