buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

Adding "Compact Constants" Option

Open CauhxMilloy opened this issue 1 year ago • 1 comments

  • Adding CompactConstantDefinitions boolean flag to tables/tables.go.
    • Can be set via tables json file (--add_tables / --tables command line or tables / addTables json config option).
    • Defaulting to false to be backwards-compatible with existing formatted files.
  • Updating compactStmt() in build/print.go.
    • If CompactConstantDefinitions is true and both statements are assignments (for const definitions), then the extra line should be removed.
    • Lower precedence than various other checks (like comment checks) to still allow extra lines when necessary.
  • Updating setFlags() in build/print_test.go.
    • Checking golden filenames for ".compactconst." to set CompactConstantDefinitions to true.
    • Adding CompactConstantDefinitions reset back to false in returned (deferred) func.
  • Copying various golden files (which contain constant definitions) to be ".compactconst." files.
    • Removing extra lines between const definitions as applicable.

Fixes https://github.com/bazelbuild/buildtools/issues/108.

CauhxMilloy avatar Feb 13 '24 07:02 CauhxMilloy

Hi, I'm not sure if I'm missing any step to get the review started? If there's something I missed, or if there's any desired changes, please let me know. Thanks!

CauhxMilloy avatar Mar 03 '24 20:03 CauhxMilloy