Skip to content

Format config sections as config, not as node tables - #242

Open
webdevred wants to merge 2 commits into
masterfrom
format-config-sections-as-config
Open

Format config sections as config, not as node tables#242
webdevred wants to merge 2 commits into
masterfrom
format-config-sections-as-config

Conversation

@webdevred

Copy link
Copy Markdown
Owner

The shipped rulesets knew about nodes, beams and a handful of table-like sections, and treated everything else the same way. That is wrong for the config objects: driveModes, mirrors, soundscape and the powertrain containers came out with their compact rows exploded across many lines, and with the numbers their authors wrote rewritten, so [0.60, 0.00] became [0.6, 0].

Formatting every jbeam in the stock vehicle zips, extracted with tools/extract-and-format-jbeam/corpus-extract.sh, these rules leave 523 files closer to how they were written, by 15380 lines. The drivemodes files gain 200 to 325 lines each.

The seven config containers use the > operator. Each was written twice before, once with ComplexNewLine: Force and again as .X.* with None, purely to stop the first rule reaching its children. PreserveNumberFormat stays in a plain rule next to it, because it has to keep reaching down. Over the 186 stock files carrying these sections, 184 format identically to the old pair of rules and two improve: both are gearbox objects holding an array with line comments in it, where forcing the array inline used to rewrite the comments into block comments.

Supersedes #179, which carried the same rules against a master 57 commits older and without the operator.

The formatter treated driveModes, mirrors, soundscape and the powertrain
objects like node tables: it exploded compact structures across many lines
and rewrote the numbers the authors wrote, turning [0.60, 0.00] into
[0.6, 0]. Over the 4943 stock jbeam files these rules leave 523 files closer
to how they were written, by 15380 lines, with the drivemodes files gaining
200 to 325 lines each.

The rules come from PR #179, which sat five months behind master. AST
fixtures regenerated with jbeam-edit-dump-ast; no example file changes,
since none of them has these sections.
Seven config containers were written twice, once with ComplexNewLine: Force
and again as .X.* with None, purely to stop the first rule reaching their
children. The > operator says that directly, so the undo rules are gone.
PreserveNumberFormat stays in a plain rule because it has to keep reaching
down into those children.

Measured over the 186 stock files that carry these sections: 184 format
identically and two improve. Both are gearbox objects holding an array with
line comments in it, where forcing the array inline used to rewrite the
comments into block comments and leave the row looking broken.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant