Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding "Compact Constants" Option #1242

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

CauhxMilloy
Copy link

@CauhxMilloy CauhxMilloy commented Feb 13, 2024

  • 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 #108.

* 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).
* 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 bazelbuild#108.
@CauhxMilloy
Copy link
Author

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!

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.

Buildifier shouldn't break up blocks of constants with newlines
1 participant